1

I want to clear all previous activity stack and launch new activity. But when i press back key control goes to previous activity. I am not finished all previous activity. When i logout i want to exit from app. I used below flags:

intentLogin.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intentLogin.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intentLogin.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intentLogin.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

and added below lines in AndroidManifest.xml

android:launchMode="singleInstance" 

But there is white screen appears before launching new activity.

I also changed theme to Translucent but while launching activity, but it shows android home icons for some moment.

I don't want to use:

moveTaskToBack(true);
Tulsiram Rathod
  • 1,926
  • 2
  • 19
  • 29

2 Answers2

0

just set this flag in intent,

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
Krunal Indrodiya
  • 782
  • 2
  • 7
  • 19
0

i hope this will help you

 logoutButton.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    SharedPreferences myPrefs = getSharedPreferences("Activity",
                            MODE_PRIVATE);

                    /*AppState.getSingleInstance().setLoggingOut(true);*/
                    setLoginState(true);
                    Log.d(TAG, "log out and go to first activity");
                    Intent intent = new Intent(HomePage.this,
                            LoginPage.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                  /*  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |   
                                       Intent.FLAG_ACTIVITY_CLEAR_TASK);*/
                    startActivity(intent);
                    finish() // finish this activity 

                }
            });
ashish.n
  • 1,234
  • 14
  • 30
  • White screen not appeared, but previous activity stack is not removed. On key back previous activity resumed that i haven't finished. – Tulsiram Rathod Apr 10 '14 at 09:17