This article describes how to use python to obtain the GPS information script of android devices. This article provides the implementation code directly. if you need it, you can refer to it on android, we can use QPython to write and execute Python scripts. It applies to many android
System functions are easily encapsulated, and it is very convenient to write small programs with simple functions using QPython.
This example is a basic script that I used to read mobile phone location information and further process data.
The code is as follows:
#-*-Coding: UTF-8 -*-
Import androidhelper
Import time
From math import radians
Droid = androidhelper. Android ()
Droid. startSensingTimed (1,250)
Droid. startLocating ()
While 1:
Gpsdata = droid. readLocation (). result
S6data = droid. sensorsReadOrientation (). result
If len (gpsdata)> 0:
Print gpsdata ['GPS '] ['bearing'] # obtain the gps orientation (angle)
If len (s6data)> 0:
Print s6data [0] # obtain the azimuth angle of the compass (azimuth) (radian)
Time. sleep (0.5)
Droid. stopLocating ()
Droid. stopSensing ()