Issue
I am trying to force my Android application to go from the onPause method directly to the onResume method by using a dialog.
I have the following code in the onClick method in my FirstActivity class which implements OnClickListener:
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.newlayout);
dialog.setTitle("This is my custom dialog box");
dialog.setCancelable(true);
dialog.show();
I've set up each lifecycle method to print out a log message when the Android app enters each method:
Log.i(ActivityName, " onCreate");
Log.i(ActivityName, " onPause");
Log.i(ActivityName, " onResume");
And so on..
When I click my button to show the dialog, the dialog shows up just fine, but I do not receive any log messages that the onPause is being called when showing the dialog and I'm not receiving any log messages that the onResume method is being called when pushing the "back" button on my phone to exit the dialog.
What am I doing wrong?
Solution
A Dialog
is always created and displayed as a part of an Activity
(take a look at this article on Dialogs). That's why your Activity
methods onResume
and onPause
are not called. When a Dialog
is displayed your Activity
is still in running state.
Answered By - droid8421
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.