开发者

Alternative to enabling data connection

开发者 https://www.devze.com 2023-03-26 06:47 出处:网络
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 alternat

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

精彩评论

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