That makes sense, but going back to the X Y Z example, I have lists in
X and Y with items that open in Z, so I go back and forth a lot
between Z and either X or Y. I want the user experience to be
seamless, and according to the performance guide
http://developer.android.com/guide/practices/design/performance.html
launching an activity (even an empty one) is one of the heaviest
operations you can do. Is there a way to reuse an activity that has
been opened once?

On May 8, 1:02 pm, Dianne Hackborn <[email protected]> wrote:
> Indeed, you can't, because singleInstance (and singleTask) means that the
> activity is managed independently of the previous activity that is launching
> it, so there can be know guarantees about when or in what order the result
> will be returned.
>
> Don't use singleInstance.
>
> Why do you want singleInstance?  You probably don't.  You have to realize
> that by doing this you are splitting your app into separate tasks, which
> will mess up the user's interaction with it as they go in and out of your
> app.
>
> As far as you using singleInstance as a way to hide the fact that your
> activity is too slow to start...  really, I would suggest fixing that
> instead. :)  If your view hierarchy takes too long to inflate, it is
> probably way overly complicated -- either with a lot of complicated layout
> managers that can be simplified, or a lot of things that are normally hidden
> that you should only inflate when needed (see Romain's articles on this for
> help).
>
> If there are other things you do that are slow, you can look at keeping
> those objects in singletons in your process so they only need to be created
> the first time the activity is started, and can be re-used thereafter as
> long as your process is aound. (But first optimize optimize optimize to try
> to make them not slow!  If your activity is so slow to start that you are
> doing this, you are making it only somewhat better by reducing the times the
> user need to wait...  there will still be many times when they still need to
> wait.)
>
>
>
> On Fri, May 8, 2009 at 5:54 AM, kingtut <[email protected]> wrote:
>
> > I basically have three activities X, Y, Z and I want only one instance
> > of each but I want control over the navigation and I can't do that by
> > putting all three activities in one task because of the stack
> > structure.
>
> > Here is a scenario, from X I launch Y given a certain "id" which
> > correspondence to specific data in the DB, Y inflates and populates
> > it's views, then I go back to X and launch Y again with a different
> > "id" in the intent, I don't want the overhead of launching the
> > activity and inflating the views again, anyone know how to do this?
>
> > I tried using singleInstance, but the problem is that I can't send the
> > result code back to an activity in a different task.
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to