Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This Works for you </p> <pre><code>package com.palewar; import android.app.Activity; import android.app.ProgressDialog; import android.os.Bundle; import android.os.Handler; import android.os.Message; public class ThreadActivity extends Activity { static ProgressDialog dialog; private Thread downloadThread; final static Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); dialog.dismiss(); } }; protected void onDestroy() { if (dialog != null &amp;&amp; dialog.isShowing()) { dialog.dismiss(); dialog = null; } super.onDestroy(); } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); downloadThread = (Thread) getLastNonConfigurationInstance(); if (downloadThread != null &amp;&amp; downloadThread.isAlive()) { dialog = ProgressDialog.show(ThreadActivity.this, "", "Signing in...", false); } dialog = ProgressDialog.show(ThreadActivity.this, "", "Signing in ...", false); downloadThread = new MyThread(); downloadThread.start(); // processThread(); } // Save the thread @Override public Object onRetainNonConfigurationInstance() { return downloadThread; } static public class MyThread extends Thread { @Override public void run() { try { // Simulate a slow network try { new Thread().sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } handler.sendEmptyMessage(0); } finally { } } } } </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