python获取android设备的GPS信息脚本分享

WBOY
Release: 2016-06-06 11:21:48
Original
1638 people have browsed it

在android上,我们可以使用QPython来编写、执行Python脚本。它对很多android

系统函数进行了方便的封装,使用QPython编写功能简单的小程序异常方便。

这个示例是我之前用来读取手机位置信息并作为进一步处理数据的基础脚本。

代码如下:


# -*- 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'] #取得Gps导向(bearing)(角度)
    if len(s6data)>0:
        print s6data[0] #取得罗盘方位角(azimuth)(弧度)
    time.sleep(0.5)
droid.stopLocating()
droid.stopSensing()

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!