I am having an issue with my app that is i need to call splashActivity
i.e. main Activity
every time when user launches an app by pressing the recent app button in the device when user has exit from the app by clicking back
/ home
buttons.
Is there anything i can do to make the things work.I tried using flag android:clearTaskOnLaunch="true"
but this is not working too.
Asked
Active
Viewed 210 times
1
-
3don't. splashscreens are evil and go against proper application flow. – njzk2 Dec 17 '12 at 13:16
-
@njzk But i really want the flow because from splashscreen i have to call appropriate activity. – anshul Dec 17 '12 at 13:20
-
1You should probably look into your [Activity LifeCycle](http://stackoverflow.com/a/8516056/1134705). – jnthnjns Dec 17 '12 at 13:27
-
post your manifest. `android:clearTaskOnLaunch="true"` should do what you want. – David Wasser Dec 17 '12 at 14:46
-
@DavidWasser this is not working – anshul Dec 18 '12 at 04:45
-
Like I said, please post your manifest. There's something strange here. We can help if you give us more information. – David Wasser Dec 18 '12 at 09:22
1 Answers
0
as interesting
When you kill process and your app visible (you see pages, not pressed home buttons)
your app be restarted
first you need this source
moveTaskToBack(true); (in you MAIN page)
android.os.Process.killProcess(android.os.Process.myPid());
or
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
android.os.Process.killProcess(android.os.Process.myPid());
or
go in you MAIN page
Intent i = new Intent(getApplicationContext(), [MAIN].class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(i, 1);
and in your main class
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid());
}

Max Usanin
- 2,479
- 6
- 40
- 70
-
1yes , you right, or how restart program..? if i understand you need destroy activity? – Max Usanin Dec 18 '12 at 08:20