Reputation: 4408
i want to exit my application when no network Before exiting i want to show a message to user Which dialogue can be used for this.
i tried to DISPLAY ALERT DIALOGUE from OnDestroy()
But its giving window leak exception
The network error is detected in asynctask where i call finish, so i dont see any other place to add dialogue.
So my question is which dialogue to add and where to add.
protected void onDestroy() {
super.onDestroy();
showExitDialogue();
Log.i("StartUpActivity", "OnDestroy");
if (asyncTaskForSync != null && !asyncTaskForSync.isCancelled())
asyncTaskForSync.cancel(true);
if (mydb != null)
mydb.close();
if (Utils.imageLoader != null)
Utils.imageLoader.stopThread();
}
private static void showExitDialogue() {
AlertDialog.Builder alert = new AlertDialog.Builder(
Utils.getStartActivityinstance());
alert.setMessage("No internet connection");
alert.setPositiveButton("Exit",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
return;
}
});
alert.show();
}
Upvotes: 1
Views: 650
Reputation: 19956
if you check network error in asynctask,then the dialog should put at the onPostExecute(Void v)
Upvotes: 1