Qpython (Android上で動くpython環境sl4aにガワをかぶせたものみたい)の練習を始める。
まずは、GPSで現在地を採ってみた。
import androidhelper
import time
droid=androidhelper.Android()
droid.startLocating()
droid.dialogCreateSpinnerProgress('position','obtaining')
droid.dialogShow()
event = droid.eventWaitFor('location')
print event
droid.dialogDismiss()
while 1:
loc=droid.readLocation()
if loc.result == {}:
loc=droid.getLastknownLocation()
if loc.result != None:
if 'gps' in loc.result:
lat = loc.result['gps']['latitude']
lon = loc.result['gps']['longitude']
print 'gps',lat, lon
elif 'network' in loc.result:
lat = loc.result['network']['latitude']
lon = loc.result['network']['longitude']
print 'network',lat, lon
time.sleep(1)
0 件のコメント:
コメントを投稿