Scenario :
I open my app by clicking icon, do something, navigate through activities, pause the app by clicking home button.
Case 1:
If I
I found it. I had set a flag android:launchMode="singleTask"
in my activity flag. I deleted that code.
I also added onsaveInstance
method to all the activities in my code and it's working now!
Thanks :)
Try to replace you splash Activity code with this code..
public class Splash extends Activity {
protected boolean _active = true;
protected int _splashTime = 2000;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while (_active && (waited < _splashTime)) {
sleep(100);
if (_active) {
waited += 100;
}
}
} catch (InterruptedException e) {
e.toString();
} finally {
Intent intent = new Intent(getApplicationContext(),
MainActivity.class);
startActivity(intent);
finish();
}
}
};
splashTread.start();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
// super.onBackPressed();
}
}
Add this to your launcher activity:
if (!isTaskRoot()) {
finish();
return;
}
super.onCreate(savedInstanceState);
seems in AndroidManifest you kept your launch activity android:launchMode="singleTask"
. remove this one from your launch activity will solve problem
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.