How to keep a single activity instance but be able to update the view?

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.

Answers


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" />

Need Your Help

Problem with const qualifiers to get private atributes of an object

c++ constructor const copy-constructor

I'm a completely new to C++ and I'm having a very stupid problem.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.