The app I'm creating needs internet connection. I am able to check if the internet is and turn on internet programmatically in android 4.2.2. But I'm not able to turn on automatically in lollipop. I searched a bit and found that the phone needs to be rooted to use setMobileDataEnabled
and getMobileDataEnabled
.
How do I redirect the user to the internet settings so he/she can turn it on. And after turning it on, how do I automatically redirect user back to my app.
I tried this based on a SO post:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(MainActivity.this,
"com.android.phone.NetworkSetting");
startActivity(intent);
But I get this error
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.prematixsofs.taxiapp/com.android.phone.NetworkSetting}; have you declared this activity in your AndroidManifest.xml?