1

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
anshul
  • 982
  • 1
  • 11
  • 33

1 Answers1

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