摘要: 一个小小Demo检测手机支持那几种传感:具体代码如下:[Java代码]DemoSensorActivity.javapackage com.example.testsensor; import java.util.List; import android.app.Activity; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorManager; import android.os.Bundle; import android.view.View; imp 阅读全文
posted @ 2013-03-23 23:32 Android_AnJon 阅读(465) 评论(0) 推荐(0) 编辑
摘要: 一个简单的小Demo测试手机方向传感:具体代码如下:[Java代码]Sample.javapackage com.example.test_sensor_orientation; import org.openintents.sensorsimulator.hardware.Sensor; import android.app.Activity; import android.hardware.SensorManager; import android.os.Bundle; import android.widget.TextView; public class Sample exten... 阅读全文
posted @ 2013-03-23 23:25 Android_AnJon 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 一个简单的小Demo 测试手机光传感:具体代码如下:[java代码]Sample.javapackage com.example.test_sensor_light; import org.openintents.sensorsimulator.hardware.Sensor; import android.app.Activity; import android.hardware.SensorManager; import android.os.Bundle; import android.widget.TextView; public class Sample extends Act... 阅读全文
posted @ 2013-03-23 23:18 Android_AnJon 阅读(214) 评论(0) 推荐(0) 编辑
摘要: AudioManager就有这个方法:isWiredHeadsetOn();如果插入了耳机,就返回true,否则false;当然,要加个权限,不然一直是返回false。 开始我追了好久的源码。发现了实时检测耳机插入和拔出的过程,不过对我的需求来说帮助不是很大。实时检测耳机插入和拔出:每当插入和拔出耳机时,系统都会发送Intent广播, 所以,只需要用一个receiver把这个广播intent(获取的action是:“android.intent.action.HEADSET_PLUG”)截获就好。这个receiver必须要用代码注册,而不能写在manifest里面用写入内存的方式。在Andro 阅读全文
posted @ 2013-03-23 15:51 Android_AnJon 阅读(1114) 评论(0) 推荐(0) 编辑