In my UI i check the network availability in a button click listner
NewButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(isInternetAvailable)
{
Intent intent = new Intent(FeaturedListActivity.this,
NewJewelsActivity.class);
startActivity(intent);
finish();
}
else
{
MyAlertDialog.ShowAlertDialog(FeaturedListActivity.this, "", "Check Network Connection.", "OK");
}
}
});
I check network availability using the following code
public boolean isNetworkAvailable() {
ConnectivityManager connectivityManager= (ConnectivityManager) getSystemService(getApplicationContext().CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
Now my problem is when i start the app with the wifi in off state the condition will work and will show the "check network connection" dialog. And now i press the center button of the phone and turn on the wifi and coming back to the screen from where i left.Now the wifi is in ON state and it still shows "check network connection".If i restart the app it will not show the dialog.How can i solve this?
}