How to display a popup image at boot time

I have an activity that contains a lot of UI views. In the onCreate method, I found that one setContentView line takes 8-12 seconds. . Therefore, I want to show my logo at boot time. I tried a lot, but without success. I suspect that the main reason may be that nothing can be shown until setContentView completes.

Any help would be appreciated.

UPDATE:

I think many people do not know that you cannot show the dialog until the completion of setContentView. Therefore, using other burst activity does not help me at all.

UPDATE2

I forgot to update this question after I found the cause of the problem. Please refer to the following question: setContentView will take a long time (10-15 seconds) to execute

+6
source share
3 answers

use AsyncTask

put a splash in onPreExecute()

and do your job in doInBackground()

and close the splash in onPostExecute()

+7
source

Below is a simple code for creating a screensaver using the CountDownTimer class

 public class SplashDialogActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.layout); counter.start(); } MyCount counter = new MyCount(5000, 1000); public class MyCount extends CountDownTimer{ public MyCount(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); } @Override public void onFinish() { go_back(); } @Override public void onTick(long millisUntilFinished) { } } public void go_back() { counter.cancel(); Intent i=new Intent(this,account.class); i.putExtra("first_time", true); startActivity(i); this.finish(); } } 
0
source

try this screen saver code

 private Thread mSplashThread; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splesh); final Splash sPlashScreen = this; mSplashThread = new Thread(){ @Override public void run(){ try { synchronized(this){ wait(5000); } } catch(InterruptedException ex){ } finish(); Intent intent = new Intent(); intent.setClass(sPlashScreen,Login.class); startActivity(intent); stop(); } }; mSplashThread.start(); } // Processes splash screen touch events @Override public boolean onTouchEvent(MotionEvent evt) { if(evt.getAction() == MotionEvent.ACTION_DOWN) { synchronized(mSplashThread){ mSplashThread.notifyAll(); } } return true; } 
0
source

Source: https://habr.com/ru/post/901790/


All Articles