Android : Can i call my onresume() inside onpause().?
<p>I want that just before my application goes in background the user should get a dialogue box asking if i want to exit this application.
And if user selects no then i want that he should be resumed to my application again instead of launching another application.
So,is it possible in android?
One solution can be like this that i call <strong>onresume()</strong> inside <strong>onpause()</strong> or <strong>onstop()</strong>.But can this be done.
Please help me out.</p>

<hr>

<p>My code is like this:-</p>

<pre><code>public void onPause() {
       AlertDialog.Builder builder = new AlertDialog.Builder(this);
       builder.setMessage("Do you want to quit");
       builder.setCancelable(false);
       builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            MytestprojectActivity.this.finish();
        }
    });

       builder.setNegativeButton("No", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

       AlertDialog alert = builder.create();
       alert.show();
       super.onPause(); 
}
</code></pre>

<p>first i basically want to see if it runs on calling of onpause() or not.
so, what i got is that it pauses my activity, goes to another activity and when my activity restarts then it shows me the dialogue box. m i missing something.?</p>
