Python gets script sharing of GPS information for android devices

  • 2020-04-02 14:38:07
  • OfStack

On android, we can use QPython to write and execute Python scripts. It works for a lot of android

The system function has carried on the convenient encapsulation, USES the QPython to write the function simple small program is extremely convenient.

This example is the basic script I used earlier to read the phone's location information and use it as a basis for further processing the data.


# -*- 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'] # achieve Gps guide (bearing)( The Angle )
    if len(s6data)>0:
        print s6data[0] # Obtain compass azimuth (azimuth)( radian )
    time.sleep(0.5)
droid.stopLocating()
droid.stopSensing()


Related articles: