how to stop open activity while splash screen killed

android splash screen while loading
how to show splash screen when app is in background in android
beautiful splash screen android
android splash screen 2020
splash screen with animation in android
splash screen android stack overflow
splash screen android kotlin
android splash screen loading animation
  1. I have splash screen .
  2. once i open my application the splash screen will appears after completion of splash screen passed intent to HomeActivity.
  3. but when i kill this app while splash screen running after some time HomeScreen will automatically open , but i want to kill the app.
  4. but the HomeScreen should not show when i killed the app .

public class SplashAnimation extends Activity {

    ImageView imageViewSplash;
    TextView txtAppName;
    RelativeLayout relativeLayout;
    Thread SplashThread;
    MediaPlayer mySong;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_view);


        mySong=MediaPlayer.create(SplashAnimation.this,R.raw.monn);
        mySong.start();
        imageViewSplash = (ImageView) findViewById(R.id.imageViewSplash);
        txtAppName = (TextView) findViewById(R.id.txtAppName);
        relativeLayout = (RelativeLayout) findViewById(R.id.relative);

        startAnimations();
    }

    private void startAnimations() {

        Animation rotate = AnimationUtils.loadAnimation(this, R.anim.translate);
        Animation translate = AnimationUtils.loadAnimation(this, R.anim.translate);

        rotate.reset();
        translate.reset();
        relativeLayout.clearAnimation();

        imageViewSplash.startAnimation(rotate);
        txtAppName.startAnimation(translate);
        SplashThread = new Thread() {
            @Override
            public void run() {
                super.run();
                int waited = 0;
                while (waited < 3500) {
                    try {
                        sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    waited += 100;
                }
                SplashAnimation.this.finish();
                Intent intent = new Intent(SplashAnimation.this, LibraryView.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
                mySong.stop();
            }
        };
        SplashThread.start();
    }

    @Override
    protected void onStop() {

        SplashAnimation.this.finish();
        finish();
        mySong.stop();
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        finish();
        mySong.stop();
        super.onDestroy();
    }
}

Once you have called SplashThread.start() it will do its job as long as it can do. I would recommend to use a Handler instead, tho you can remotely cancel the task, the Handler runs:

//init and declare the handler instance
private Handler delayHandler;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (delayHandler == null) {
        delayHandler = new Handler();
    }
    //your code
}

//define the task the handler should do
private void startAnimations() {
//replace the code beginning at 'Thread SplashThread = new Thread()' with the following
delayhandler.postDelayed(new Runnable() {
    @Override
    public void run() {
        Intent intent = new Intent(SplashAnimation.this, LibraryView.class);
        //these flags will prevent to 'redo' the transition by hitting the back button, that also makes calling 'finish()' obsolete
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);            
        startActivity(intent);
    }
//instead of the while loop just execute the runnable after below given amount of milliseconds
}, 3500)

//to remotely cancel the runnable, if the app, respectively the Activity gets killed override 'onDestroy()'
@Override
public void onDestroy() {
    super.onDestroy();
    mySong.stop();
    //calling 'finish()' is obsolete, tho 'finish()' calls 'onDestroy()' itself
    //tell the handler to quit its job
    delayHandler.removeCallbacksAndMessages(null);
}

how to stop open activity while splash screen killed, I have splash screen . once i open my application the splash screen will appears after completion of splash screen passed intent to HomeActivity. but when i kill  The splash screen showing again if the activity was killed and recreated by the system. In most cases, this is not a very serious issue, but you can use Method 2 to fix it. Some developers want to have a dedicated splash screen Activity that routes to different pages based on some state after the splash screen is done.


Call in onStop() method

SplashThread.interrupt()

how to stop open activity while splash screen killed, once i open my application the splash screen will appears after completion of splash screen passed intent to HomeActivity. but when i kill this app while splash​  1 how to stop open activity while splash screen killed Dec 13 '18 0 onbackpressed not working in kotlin webview Dec 13 '18 0 How to show all notification in statusbar until user click in android FCM Like Whatsapp Jun 20 '18


You can use Timer instead of instantiating the Thread class.

Refer the code below to start the Activity after 4 seconds. Use this in onCreate() of SplashActivity.

timer = new Timer().schedule(new TimerTask() {          
    @Override
    public void run() {
        startActivity(new Intent(getApplicationContext(), MainActivity.class));
    }
}, 4000);

In your onPause() method use:

timer.cancel()

This will terminate the timer and disregards any currently scheduled tasks.

Android Boot Camp for Developers Using Java: A Guide to Creating , Life and Death of an Activity 231 In Line 15 of the Aloha Music app, as shown in cycle, which is the series of actions from the beginning of an Activity to its end. when the scheduled timer starts (Line 26 in Figure 6-11), the SplashActivity is paused. If you open multiple apps on a smartphone and receive a phone call, you  For the Love of Physics - Walter Lewin - May 16, 2011 - Duration: 1:01:26. Lectures by Walter Lewin. They will make you ♥ Physics. Recommended for you


Hangs on splashscreen when reopening app with tap on app icon , It also shows the splash screen when launch it from the Task Manager? opening the app via a push notification when the app is killed. (i.e. splash screen) in activity stack when it shouldn't, so that you can end up with an  Splash screen is the initial screen when user opens the app. It basically contains branding items like logo, slogan and company name etc. It also known as the boot screen. If you want to execute a long task and get the result to show as the content of the next page then Splash screen is the best place to execute that long running task.


The (Complete) Android Splash Screen Guide, In the past, having splash screens in your Android app were not recommended. Well, when Material Design dropped with a pattern called Launch Screen (​Splash While you could just use a simple image, it will end up stretched to fill the The splash screen showing again if the activity was killed and  The right way of implementing a splash screen is a little different. In the new approach specify your splash screen’s background as the activity’s theme background. Also the root cause of blank white page problem is that your layout file is visible only after app has been initialized completely. Do not create a layout file for splash activity.


Closing Android app during splash screen still opens feed, Kill app if needed; Start app; During splash screen, press back or home; Wait​??? Feed activity starts. Using v0.1.41 on  Today we're creating a splash screen / welcome screen for our android app. Do you know that welcome window for an android app make it seem professional for the user. So how it done ?