Save the state of the main activity

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Save the state of the main activity

Postby puxdroid » Sun Jan 10, 2010 3:55 pm

Hello
I have a main activity with a ToggleButton, but when I press the terminal "home" button and run my application again, I lose the state of the firs activity showed. (And I manage some threads with ToggleButton)

Anybody knows any tutorial or method to solve this problem?

Thanks in advance (and sorry for my English)!
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Top

Postby michael1221988 » Sun Jan 10, 2010 6:14 pm

You should store your information in a bundle. Look here for an example.
michael1221988
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri Jan 08, 2010 4:39 am

Postby puxdroid » Sun Jan 10, 2010 7:48 pm

I have followed this example but "onRestoreInstanceState" method never run, only run the methods "onResume()" and "onPause()".

Other problem is that if I run the application again and press the "back button", it show me the first activity, the activity what I want...

The other problem is that I have a thread instance to stop the a service, but with Bundle I don't know how to get the thread instance and stop it.
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Postby jagtap.jj1 » Mon Jan 11, 2010 8:46 am

puxdroid wrote:Other problem is that if I run the application again and press the "back button", it show me the first activity, the activity what I want...


Use clearTaskOnLaunch= true in AndroidManifest.xml, http://developer.android.com/reference/ ... skOnLaunch
java-android developer
User avatar
jagtap.jj1
Senior Developer
Senior Developer
 
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)

Postby puxdroid » Mon Jan 11, 2010 10:27 am

jagtap.jj1 wrote:Use clearTaskOnLaunch= true in AndroidManifest.xml, http://developer.android.com/reference/ ... skOnLaunch


"clearTaskOnLaunch= true" don't work :( I have the same problem...
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 5 guests