Persistant Variables

by Kirk » Tue, 14 Apr 2009 02:27:28 GMT

Sponsored Links
 I have an activity that responds to the accelerometer. When the device
is rotated, a different layout is displayed based on whether the phone
is portrait or landscape. I notice, however, that each time the phone
is rotated, the onCreate method is called and all of my instance
variables are reset. Is there any way to make the values of these
variables persists?



Persistant Variables

by MrChaz » Tue, 14 Apr 2009 02:32:11 GMT

 Take at look at on onSaveInstanceState()
You can use that to save things into the bundle that is passed to


Sponsored Links

Persistant Variables

by Kirk - Actual Metrics » Tue, 14 Apr 2009 04:07:27 GMT

 Thanks that works great. I feel kind of stupid for not figuring that
out on my own now.  I do think it's silly for onCreate to be called
again on rotate; there should be an onOrientationChange event or



Persistant Variables

by MrChaz » Tue, 14 Apr 2009 04:26:32 GMT

 I think that there is a permission for saying that you will handle it
and another event that you can hook.
But I've not explored those :)

On Apr 13, 8:49pm, Kirk - Actual Metrics <>


Persistant Variables

by Dianne Hackborn » Tue, 14 Apr 2009 05:54:02 GMT

 The docs explain why it works the way it does.

On Mon, Apr 13, 2009 at 12:49 PM, Kirk - Actual Metrics <

Dianne Hackborn
Android framework engineer

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.


Other Threads

1. Complete Action using Dialog to view a JPEG

You mean the system one? Fire ACTION_VIEW intent with right mime type and
let OS handle it. Keep in mind it may show up only if there's anything too
choose from (if there's just one viewer (i.e. gallery) then it won't pop up
because it'd simpy be pointless) or user not decided to make app of his
choice a default viewer last time.

Marcin Orlowski

*Tray Agenda <>* - keep you daily schedule handy...
*Date In Tray* <> - current date at glance...
WebnetMobile on *Facebook <>* and


2. ActivityGroup, when i press back the activity does not reload itself...

Hi everybody!

I have a tabhost on my application and I'm using an Activity group
which handles 3 activities inside.

ActivityGroup Handles
 A -> B -> C

When i start this activities i'm using the flag

My problem is when the user goes from A->B->C and press back button,
my B activity shows up, but it does not resume or reload or refresh.
It has the same state as before.

For example if the user goes again to C, C is refreshed, but when from
C goes back.... B is not.

  On B I have implementend methods such as onResume, onStart,
onReestart and debugging it the main thread never goes in there...

And i need to refresh B because C can make changes that change the
content displayed on B.

I have googleled this for 3 days and I couldn't found a solution..


3. a problem about ACTION_TIME_TICK

4. How can i stop to envoke onDrawFrame

5. Appwidget + AsyncTask + Handler

6. Mindahin widget

7. Problem with listview