Automatically reopen Android app when it closes
2 answers
You can simply prevent the application from closing with the back button by overriding onBackPressed()
@Override
public void onBackPressed() {}
Now the user cannot exit the application by pressing the "Back" button.
OR to achieve what you want. Have this method ...
@Override
public void onDestroy() {
super.onDestroy();
Intent i = new Intent(this, ActivityName.class);
startActivtiy(i);
}
This above code will start action when it is destroyed. I have not tested it to make sure it works.
0
source to share
The OS decides whether it needs to kill the application or not. Wanting an app to always work is a bad technical and UX decision.
Background services are designed to cover these use cases. Your UI may not necessarily be visible, but your service will register Broadcast receivers to receive event notifications and ultimately launch the app / show the notification.
0
source to share