Hi Prajakta,

I think you might be mistaken about the use of "onSaveInstanceState()"
method in an Activity. It is useful only when the Activity is about to
be killed and expected to be restored later by the system. Otherwise,
the information saved when the method is called is not reused.

If Activity A starts Activity B then user presses "back" to Activity
A. The Activity B will always be destroyed, which means a new instance
of Activity B will always be created when it is called again by
Activity A, *unless* Activity B is the already in the task and the
singleTask/singleInstance launchMode is set. The Activity B will only
exist in the task if it's the root activity or previously started by
other Activities without being destroyed. E.g

C -> B -> A -> B

In that sense, the same instance of Activity B will be reused if
singleTask/singleInstance is set. Otherwise new instances of Activity
B will be created.


Makas

On Mar 14, 1:31 am, Prajakta Shitole <[email protected]> wrote:
> Hi Makas,
>
> Thanks for your suggestion, but when I tried changing it to singleTask, I
> still could not start my activity. It kept giving me NullPointerException as
> my activity expects a Bundle. I had even stored the values that I needed
> from the bundle in my OnSaveInstance method, but dint get it to work.
>
> However when I tried using a service and created a new activity I was able
> to get my functionality running, but I would like to get the same activity
> which was created earlier to the foreground.
>
> I will look into this again by changing the launchModes and debugging and
> will let you know if that worked.
>
> Thanks,
> Prajakta
>
> On Sat, Mar 13, 2010 at 1:53 AM, Makas Tzavellas
> <[email protected]>wrote:
>
> > Hi Prajakta,
>
> > By default, an activity will be "destroyed" (onDestroyed() will be
> > called) being called when the "back" button is called. E.g A calls B,
> > and user presses the "back" button, then activity B will be destroyed.
> > So from calling activity B again from activity A will create a new
> > instance of activity B (onCreate() will be called).
>
> > So if I understand you right, you would like to use the same instance
> > of Activity B instead of recreating a new instance each time the
> > Activity is called from other activities. Therefore, you *might* want
> > to use "singleTask" as the Activity's "launchMode".
>
> > You can find out more information from here.
>
> >http://developer.android.com/guide/topics/fundamentals.html#lmodes
>
> > On Mar 13, 9:25 am, Prajakta Shitole <[email protected]> wrote:
> > > Hi Jeffrey,
>
> > > Thanks for the suggestion but I have activities and not views. I have
> > > separate activities which are being called so I am not sure how I will be
> > > able to achieve the same thing that you have implemented.
>
> > > Thanks,
> > > Prajakta
>
> > > On Fri, Mar 12, 2010 at 10:19 AM, Jeffrey <[email protected]>
> > wrote:
> > > > What I have done with success in some of my apps is making several
> > > > parent views that hold each layout within a table layout, and use the
> > > > menu buttons to change the visibility of the parent view containing
> > > > the info you want them to see. Since the view is never really closed,
> > > > it's state is kept. Just use setVisibility(View.GONE) or View.VISIBILE
> > > > and it should keep everything good.
>
> > > > Just make sure that each button press hides all the other parent views
> > > > or else you will basically end up with two screens showing one after
> > > > the other.
>
> > > > On Mar 12, 7:21 am, TreKing <[email protected]> wrote:
> > > > > On Fri, Mar 12, 2010 at 12:28 AM, Prajakta Shitole <
> > [email protected]
> > > > >wrote:
>
> > > > > > One of my idea was to store the picture and the text view in the
> > > > service
> > > > > > and on click of a menu button navigate to another activity which
> > will
> > > > > > connect to the service and draw the stored pictures, text views in
> > its
> > > > > > activity.
>
> > > > > I haven't done anything like this but this seems like what you would
> > want
> > > > to
> > > > > do.
>
> > ---------------------------------------------------------------------------­----------------------
> > > > > TreKing - Chicago transit tracking app for Android-powered
> > deviceshttp://
> > > > sites.google.com/site/rezmobileapps/treking
>
> > > > --
> > > > 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]<android-developers%[email protected]>
> > <android-developers%[email protected]<android-developers%[email protected]>
>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > 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]<android-developers%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
>

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