Reputation: 2329
I am making a check if the user is connected to the internet. If the user is not connected then prompt the user to turn on data services.
This is the code that I am using to prompt the user to turn on data services if not connected
@Override
public void onClick(DialogInterface dialog, int which) {
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
dialog.dismiss();
}
The above code works fine but it opens the wifi settings. Please how can I modify the code to open the image shown below
Upvotes: 0
Views: 613
Reputation: 154
public boolean isNetworkAvailable() {
ConnectivityManager connectivity = (ConnectivityManager) ctx
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
} else {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
Upvotes: 1