Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show dialog box from asyntask nonUI activity in android?
    text
    copied!<p>i have implemented code form the below link to check the idle time of the application <a href="https://stackoverflow.com/questions/11533613/how-to-intent-to-another-page-on-android-pop-up-a-message-from-idle-time">How to intent to another page on android/pop up a message from idle time?</a></p> <p>Instead using thread i used asyntask...Now my problem once it reaches the idle time..i want to show dialog to the user application is end relogin from the login activity.. How can i call dialog from the asynctask onpostExcute </p> <pre><code>public class session extends AsyncTask&lt;Void,Void,Void&gt; { private static final String TAG=session.class.getName(); private long lastUsed; private long period; private boolean stop; Context context; final Dialog dialog = new Dialog(context); @Override protected Void doInBackground(Void... params) { // TODO Auto-generated method stub //here i do the process....... } @Override protected void onPostExecute(Void x){ //stuff to be done after task executes(done on UI thread) // For Dialog Button********************************** dialog.setContentView(R.layout.dialog); dialog.setTitle("Result"); final TextView dialogtxt = (TextView) dialog .findViewById(R.id.textView1); final Button closeButton = (Button) dialog .findViewById(R.id.button1); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub dialog.dismiss(); } }); dialogtxt.setText("session time out"); dialog.show(); // **************************************************** } @Override protected void onPreExecute(){ //stuff to be done after task executes(done on UI thread) } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload