Skip to content

Instantly share code, notes, and snippets.

@riverfor
Created January 30, 2020 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riverfor/7ca4c7e22895ce01673987d4272d5c19 to your computer and use it in GitHub Desktop.
Save riverfor/7ca4c7e22895ce01673987d4272d5c19 to your computer and use it in GitHub Desktop.
import time
from androidhelper import Android
droid = Android()
droid.startLocating()
locproviders = droid.locationProviders().result
print("locproviders:"+repr(locproviders))
gpsprovider = droid.locationProviderEnabled('gps').result
print("gpsprovider:"+repr(gpsprovider))
i = 0
while i<100:
event = droid.eventWaitFor('location', 10000).result
print("Event:"+repr(event))
location = droid.readLocation().result
if len(location) > 0:
print('Location:'+repr(location))
else:
location = droid.getLastKnownLocation().result
print("Last location:"+repr(lastloc))
loc = location['network'] # change to gps if you can get it
addr = droid.geocode(loc['latitude'], loc['longitude']).result
print("addr:"+repr(addr))
time.sleep(1)
i = i+1
droid.stopLocating()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment