Note that there are some explanatory texts on larger screens.

plurals
  1. POAsynchtask with splashScreen
    text
    copied!<p>i want to murge between splash screen with shown first with asynchtask on my application , i start with splash 5 seconde , then asynchtask , i want that when i start my splash also asynchtask start to load , this is my splash code : </p> <pre><code>public class SplashActivity extends Activity { private static String Spsc = SplashActivity.class.getName(); private static long time = 5; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar setContentView(R.layout.splash); IntentLauncher launcher = new IntentLauncher(); launcher.start(); } private class IntentLauncher extends Thread { @Override public void run() { try { Thread.sleep(time*1000); } catch (Exception e) { Log.e(Spsc, e.getMessage()); } Intent intent = new Intent(SplashActivity.this, MainActivity.class); SplashActivity.this.startActivity(intent); SplashActivity.this.finish(); } } } </code></pre> <p>and this is my splash from mainActivity : </p> <pre><code>class FetchPosts extends AsyncTask&lt;Void, Void, Void&gt; { private ProgressDialog progressDialog; @Override protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(MainActivity.this, "", getString(R.string.loading_message)); } @Override protected Void doInBackground(Void... params) { articles = Services.getPosts(MainActivity.this); return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); progressDialog.dismiss(); } } </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