if(haveNetworkConnection()==false)
{
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Info");
alertDialog.setMessage("Internet not available, Cross check your internet connectivity and try again");
alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
alertDialog.show();
}
I am checking the internet connection at the start of my app and if not connected then it should show a alert message, and on pressing ok should exit the app.This code does not work.
Since you haven't provided any code for haveNetworkConnection() try replacing with this