I have an activity which displays data and before everything starts I do a check whether there is internet or not. If there isn't I send the user to the Wifi settings.
The problem I am facing is that after the user does connect to the internet and presses back, the app is empty without the data. Is there a way to reload this activity or recreate it?
I tried this code but it recreates the activity before I go to the settings so the dialogue box stays open
@Override
protected void onResume() {
super.onResume();
this.onCreate(null);
}
This is the code that checks the internet connection
if(!isNetworkAvailable()){
//Toast.makeText(getApplicationContext(), "internet is not avialable", Toast.LENGTH_LONG).show();
AlertDialog.Builder ad = new AlertDialog.Builder(this);
ad.setMessage("There is no Internet Connection.\n Please check your settings.");
ad.setCancelable(false);
ad.setPositiveButton("Internet Settings", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
}
});
ad.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
finish();
}
});
ad.show();
}