StartActivity in onPause () does not work after opening a new application

I start the second action when my first action is paused.

FirstActivity.java

@Override
public void onPause(){
    super.onPause();
    startActivity(new Intent(this, SecondActivity.class));
}

When I click on the home screen button, SecondActivity will start, but with a delay. There is enough time in this delay to open a new application (for example, a messenger). However, when I open a new application, SecondActivity will no longer start (it will not even call the onCreate SecondActivity method).

How can I launch SecondActivity even when I open a new application?

+4
source share
2 answers

onBackPressed() onPause().

@Override
public void onBackPressed()
{
    startActivity(new Intent(this, SecondActivity.class));
    super.onBackPressed();
}
0

, , , onStop, onPause. : singleInstance

<activity ..
  android:launchMode= "singleInstance" />

, onStop() () . . .

0

Source: https://habr.com/ru/post/1627450/


All Articles