I have three activity: - SplashActivity - MainActivity - PlayerActivity
Of course the app starts with SplashActivity, then it starts MainActivity and closes. MainActivity in some moment starts PlayerActivity and goes to backstack. (MainActivity is alive but is onStop) Then I need open MainActivity and set PlayerActivity to background (PlayerActivity is alive but is onStop). Then I need open PlayerActivity again and set MainActivity to background.
So PlayerActivity and MainActivity often gets onPause() and onStop() without onDestroy when app switch one to another and back.
I need finish all activities and start app for SplashActivity each time when user will push "home" button but home button makes the same like switch between activities (onPause() and onStop()). So I can not catch the difference to kill activities.
Please help.
EDITED: Unfortunately, onUserLeaveHint doesn't help, it's the same. If User pushes HOME this calls:
onUserInteraction, onUserLeaveHint, onPause, onStop
This Activity return previous Activity (Main) without any users actions.
public class PlayerActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_next);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(PlayerActivity.this, MyActivity.class));
}
}, 5000);
}
}
But still have the same:
onUserInteraction, onUserLeaveHint, onPause, onStop
SplashActivity
, if you do nothing in it. – Philippeville