android 代码 操作 gps 开关
2011-12-06 21:45
211 查看
在研究android gps 的时候,发现android系统隐藏了对gps开关操作的接口,也不知道为什么,个人觉得可能是怕所有的程序都区操作gps 开关从而导致混乱吧!但是还是在网上看到了一个用代码对gps 开关进行操作的方法。 贡献出来!
====================================================================================
直接上代码:
private voidtoggleGPS() {
IntentgpsIntent = newIntent();
gpsIntent.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
gpsIntent.addCategory("android.intent.category.ALTERNATIVE");
gpsIntent.setData(Uri.parse("custom:3"));
try {
PendingIntent.getBroadcast(this, 0,gpsIntent, 0).send();
}
catch (CanceledExceptione) {
e.printStackTrace();
}
}
====================================================================================
直接上代码:
private voidtoggleGPS() {
IntentgpsIntent = newIntent();
gpsIntent.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
gpsIntent.addCategory("android.intent.category.ALTERNATIVE");
gpsIntent.setData(Uri.parse("custom:3"));
try {
PendingIntent.getBroadcast(this, 0,gpsIntent, 0).send();
}
catch (CanceledExceptione) {
e.printStackTrace();
}
}
相关文章推荐
- Android中使用代码开关GPS、移动网络(GPRS)、WiFi
- Android用代码实现GPS的开启/关闭功能+网络开关
- Android 在代码中设置打开关闭GPS不必用户操作
- Native.js获取监听开关等操作Android蓝牙设备实例代码
- Android中使用代码开关GPS、移动网络(GPRS)、WiFi
- Android中使用代码开关GPS、移动网络(GPRS)、WiFi
- android代码混淆操作
- Android6.0/7.0上 添加对开机铃声的开关控制操作
- Android动画 实现开关按钮动画(属性动画之平移动画)实例代码
- android文件操作相关代码
- android中修改framework层代码后怎样操作才能看到修改后的效果?
- 代码控制android手机的网络开关。
- Android在代码中打开Wifi、移动网络和GPS
- Android的GPS的代码分析(一)
- Android GPS —— 概念和基本操作
- Android移动开发-通过自定义算法代码来纠偏地图由GPS定位到的经纬度在地图上显示或解析位置时出现偏移的问题
- 代码中开关Wifi、移动网络和GPS
- 结合枚举类型和异或操作实现开关 --使代码更清晰
- Android 监听WiFi的开关状态实现代码
- Android的ListView多选删除操作实现代码