【问题标题】:Android Python get gps statusAndroid Python获取gps状态
【发布时间】:2012-02-21 19:57:24
【问题描述】:

来自 Symbian PyS60 的 Android Python 脚本的新功能。我想将我的 gps info PyS60 应用程序移植到 Android sl4a Python。我可以得到位置,但仅此而已。从 API 文档和 Java 示例来看,似乎是这样的: 将 android.location.LocationManager 导入为 lm 状态 = lm.getGpsStatus() 会做的伎俩,但我无处可去。 请帮助我走上正轨(也许是cython???) 谢谢,詹威廉

【问题讨论】:

    标签: android python gps sl4a


    【解决方案1】:

    使用 GPS 的 Python 代码的简短示例:

    import android, string, time
    droid = android.Android()
    droid.startLocating()
    time.sleep(10)
    l = droid.readLocation()
    

    我在 sl4a 的教程页面中找到了这个 http://code.google.com/p/android-scripting/wiki/Tutorials 其中之一被称为:“跟踪你去哪里!Lua 示例和 python 脚本来跟踪你的位置。”

    完整的文档在 LocationFacade 中 这里:http://www.mithril.com.au/android/doc/

    【讨论】:

      【解决方案2】:
       import android, time
       droid = android.Android()
       droid.startLocating()
       time.sleep(15)
       loc = droid.readLocation().result
       if loc = {}:
         loc = getLastKnownLocation().result
       if loc != {}:
         try:
           n = loc['gps']
         except KeyError:
           n = loc['network'] 
         la = n['latitude'] 
         lo = n['longitude']
         address = droid.geocode(la, lo).result
       droid.stopLocating()
      

      【讨论】:

      • 希望对您有所帮助! :)
      猜你喜欢
      • 1970-01-01
      • 2013-04-29
      • 2011-05-09
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 2023-03-22
      • 2015-05-23
      • 2015-06-30
      相关资源
      最近更新 更多