I have this output from using the readLocation() method from the SL4A API. This is the result. How can I parse this so I only get altitude, longitude, and latitude?
Result(id=2, result={u'network': {u'altitude': 0, u'p
rovider': u'network', u'longitude': -97.6591116000000
03, u'time': 1329794430482L, u'latitude': 30.44257223
3333333, u'speed': 0, u'accuracy': 51}}, error=None)
I tried it with this code:
import android, string, time
droid = android.Android()
droid.startLocating()
time.sleep(5)
res = droid.readLocation()
print res.result[u'latitude']
It returned:
KeyError: u’latitude’
Assuming
resis the name bound to that object,res.result[u'network'][u'altitude']will get you the altitude. Modify as appropriate for the other keys.