As you can see, finish () is what you want to use to kill activity. The ACR path will work, however it will only restart your activity, and not really kill the process and start it. If this is what you are looking for, instead of having a dummy activity that restarts the original activity, using flags is the right way to do this.
Intent i = new Intent(this, WrapperActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i);
These flags will clear your back stack right up to the first instance of any activity you create, it will kill it, and then create a new one. This is essentially what the ACR example does, but it is much more concise.
If this is not enough for you, in order to do it right, this is quite a lot of work and requires more in-depth knowledge of the Android system. You want to create a service that runs in the background (there must be a separate process if you want the application level state to be killed) that you could launch when you want to kill the application, ask the application to kill itself or the service will kill the application for you, and then start the launch of the service, which will start your activity / application.
Hope this helps! Good luck
source share