2

On android 2.3 the permission <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> is not allowed anymore for non-system applications. Is there 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

2 Answers2

0

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);
A. Abiri
  • 10,750
  • 4
  • 30
  • 31
  • Yes, I know how to work with wi-fi, but data connection is the problem here. –  Aug 08 '11 at 06:53
0

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.