In my situation, there is one case in which I need to make sure the activity only runs one at a time.
I found if I set the LauchMode
of the activity, I can reach the single instance aim, but it won't update the view of the activity.
This activity is launched by startActivityForResult
, and we send the URI with the intent to the activity.
Let's discuss with this certain case:
gallery - lauch this activity with imageA.
camera - lauch this activity with imageB.
My request is not to destroy the old activity, but the activity that just received the new intent infomation should refresh the view.
I found a new method, onNewIntent
.
This method can refresh the intent before resume. I will try it.
You can have an Activity with a manifest attribute of singleInstance. As soon as the activity is relaunched , onResume gets called. You can update the view with the new image and invalidate the older View.
<activity ..
android:launchMode= "singleInstance" />