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()
使用GPS的python代码的一个简短示例:
我在sl4a的教程页上找到了这个 http://code.google.com/p/android-scripting/wiki/Tutorials 其中一个叫做:“追踪你的去处!Lua示例和python脚本来跟踪您的位置。”
完整的文档在LocationFacade中 这里:http://www.mithril.com.au/android/doc/
相关问题 更多 >
编程相关推荐