Android app restarts when opened by clicking app icon

后端 未结 5 554
情书的邮戳
情书的邮戳 2021-01-04 00:00

Scenario :

I open my app by clicking icon, do something, navigate through activities, pause the app by clicking home button.

Case 1:

If I

5条回答
  •  旧时难觅i
    2021-01-04 00:48

    In current activity set some image which needs to be displayed for 2 seconds like below.

    ImageView im = new ImageView(this);
    im.setImageResource(set your image);
    setContentView(im);
    intentMainScreen = new Intent(getApplicationContext(), MainScreen.class);
    Handler x = new Handler();
    x.postDelayed(new splashhandler(), 2000);
    

    Then start your activity in the SplashHandler class (which implements runnable and call start activity in run method).

    It will display your Splash screen for 2 seconds and start another activity.

提交回复
热议问题