Reputation: 63
I am making a splash screen and need help closing this activity so if a user presses the 'BACK' button they go back to the home screen, NOT the splash screen...
package com.Sosotech;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splashscrn extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscrn);
Handler x = new Handler();
x.postDelayed(new SplashHandler(), 5000);
}
class SplashHandler implements Runnable {
public void run() {
startActivity(new Intent(getApplication(), Main.class));
}
}
}
PS: I just want to know if it is possible to make the splash screen come up every time the app is resumed. I will not be implementing this, I just wondered how it would be done.
Upvotes: 0
Views: 2096
Reputation: 22040
To close the activity:
Splashscrn.this.finish();
For your PS
Set the activity as your main, launching activity and set clearTaskOnLaunch to true in the manifest.
Upvotes: 1
Reputation: 24031
use finish() as:
startActivity(new Intent(getApplicationContext(), Main.class));
finish();
Upvotes: 1