I have an Activity that I consider a critical operation (Specific communication with another computer over Bluetooth) and I want to make it so that when the user leaves the activity, it cannot be resumed to that state. With other words, if the user resumes the activity it should be recreated.
Since this activity uses Bluetooth it might start one or two activities for result (Enable-Bluetooth activity
and Request-Permissions activity
) and therefore, I cannot simply finish()
the activity in onPause()
.
By leaving the Activity, I mean presses the home button, takes a phone call or presses the multitask button
I have experimented with some Activity Launch modes (like singleTask) without success.
I already call super.onCreate(null)
in the Activity's onCreate()
method, preventing it from recreating to a specific state after it has been destroyed, but I want to reset the activity whether onDestroy()
has been called or not.
Does anyone have any suggestions on how this should be done correctly?
Edit:
The question in the Possible duplicate explains how to quit an application and it's subtasks completely (whereas just finish()
would suit my needs perfectly - if I knew where to call it). This question is about finding a clean way to not resume the previous state of the Activity.