Android怎样监听并打开关闭GPRS? 从网上搜了很久,资料比较少,搜出来的好像也不能用,不知道怎样打开和关闭GPRS呢,监听已经可以了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Intent gpsIntent = new Intent(); 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(FusionField.currentActivity, 0, gpsIntent, 0).send(); } catch (Exception e) { UtilLog.e("LogicFacade........toggleGPS", e.getMessage()); } 上面的方法是:GPS没有打开则会打开,GPS已经打开则会关闭 这里要加入什么权限,我加入了如下,好像还是不行呀<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> 貌似楼主问的是GPRS,not GPS,不过谢谢分享。。 http://www.cnblogs.com/rollrock/archive/2011/07/04/2097193.html应该是可以的,但是不知道可不可以后台操作。你的广播是后台操作,这个就不知道了,你先试试apn开关吧,网上apn开关的例子很多 帮忙看看 phonegap 如何监视wifi中热点的切换 模拟器中可以模拟gps吗?? Android编译问题 编译最新版本的android2.2,找不到javax.tools包,编译报错 FFMpeg通过JNI在本地C++代码中实现Surface显示 android 菜单问题 进入fastboot模式后,电脑连不上手机怎么办 Android4.4中Email打开网页URL问题-欢迎大家来讨论 关于触摸事件的。。来人帮看下什么情况! 播放m3u8问题
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(FusionField.currentActivity, 0,
gpsIntent, 0).send();
} catch (Exception e) {
UtilLog.e("LogicFacade........toggleGPS", e.getMessage());
}
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
应该是可以的,但是不知道可不可以后台操作。你的广播是后台操作,这个就不知道了,你先试试apn开关吧,网上apn开关的例子很多