开发者

Alternative to enabling data connection

On android 2.3 the permission <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> is not allowed anymore for non-system applications. Is th开发者_如何转开发ere an alternative to enable/disable data connection, besides that one where you modify APN name? I found Data Enabler Widget on Android Market that does that, but I can't seem to understand how. Can anyone help me?

Thanks! - Alex Ady


I don't know how to change data connection (3g, 2g, etc), but you can enable/disable wifi connection through this:

WifiManager wifiManager = (WifiManager)this.getSystemService(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(boolean enabled);


I found a solution to my problem, so I'm closing this question. The alternative is to simply display the mobile settings activity if a level 10 API or higher is detected, or continue with direct enable from code otherwise. I keep the android.permission.MODIFY_PHONE_STATE, but only use it the API is under level 10.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜