Android传感器与LBS

1.Android中传感器的使用:

使用步骤:

SensorManager lets you access the device's sensors. Get an instance of this class by calling Context.getSystemService() with the argument SENSOR_SERVICE.

通过SensorManager来获取Sensor,它实际上是一个SystemService,所以通过Context.getSystemService(SENSOR_SERVICE)来得到。

SensorManager的getDefaultSensor方法可以获取具体的传感器类型,传感器的类型有很多种,根据传入的TYPE来选择自己想要的传感器:

这里我们通过实现SensorEventListener接口来写当传感器感应到的数值发生变化时需要做出的响应事件。

其中onSensorChanged就是传感器数值发生变化时调用的方法,在这里做具体的响应事件。

onAccuracyChanged是当精度发生改变时调用的方法。

在注册时我们传入Listener,sensor实例,和一个表示传感器接受更新速度的值。

使用时注意:

2.LBS:这里我们使用的是百度地图的SDK。

这里主要是根据网站上提供的开发指南进行具体操作。

详情参看链接:http://lbsyun.baidu.com/index.php?title=androidsdk/guide/buildproject

results matching ""

    No results matching ""