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. Social networking gateway performance....

Hello All....

I think Social NetWorking sites which support on Mobile will get data
from SNG(Social Networking Gateway).

SNG will get mass data from all the social networks and send to phone
that means SNG acts as server.

I want to know performance,scalabilty etc.... of SNG. Is there any
process to measure?



2. help in service

Hi there,

I have been doing with the android for a while, but I am totally confused
with the service part.

I can create a service, start / stop from the activity.


I have seen many examples but besides clearing, they have infact confused me


But what I need is that the service as response from web request launches a
intent (within the same application package) and bring it to front. Also I
want activity (same application but different from the one that created
service) to get variables in the service or use methods declared in inshort 2 requirements for now:

1.     Basically how to get the instance of the service from another

2.     Call the specific activity / intent from the service and getting it
on front.


For example, from the server end I may send relogin request, for which the
service will call clear the local login status and show login activity.

So far what I have been able to do is call notification manager..


But there must be some other way to sort things.


Thanks in advance




+1   360-215-1917

+1   978-728-9338 <> 




3. Display flicker when a video is played

4. Any Tree (Swing/JTree-like) widget for Android?

5. Custom Contact Fields

6. standard UI style for "there's more..." ?

7. Forcing Sensor Readout?