Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old January 26th, 2012, 11:26 AM   #1 (permalink)
Junior Member
 
jonathanrz's Avatar
 
Join Date: Jan 2012
Location: Brazil - Blumenau, SC
Posts: 69
 
Device(s): Motorola Defy - Gingerbread(2.3.3)
Thanks: 12
Thanked 5 Times in 4 Posts
Send a message via MSN to jonathanrz jonathanrafaelz
Question Doubt about Activities life cycle

Hi

I have an application that have two activities, lets name they A and B for convention.

A calls B.

In activity B, I implemented the method onSaveInstanceState to save data members on the Bundle, and in the method OnCreate I implemented to take the datas from the Bundle.

Everything is working fine, but if I kill the application or restart the fone, the application starts with activity A, how can I inform to Android that he have to call activity B or what I have to implement?

I believe that restart the fone is a way to simulate the Android procedures when he will kill my application because low memory. Am I right?

Sorry for the bad english.

jonathanrz is offline  
Reply With Quote
Sponsors
Old January 26th, 2012, 01:54 PM   #2 (permalink)
Junior Member
 
jonathanrz's Avatar
 
Join Date: Jan 2012
Location: Brazil - Blumenau, SC
Posts: 69
 
Device(s): Motorola Defy - Gingerbread(2.3.3)
Thanks: 12
Thanked 5 Times in 4 Posts
Send a message via MSN to jonathanrz jonathanrafaelz
Default

I'm having another problem too, in the same application, I have three activities, lets name they A, B and C for convention.

A calls B with StartActivity.
When user hit the back/cancel button, I have to call Activity C, so I implemented in OnPause function to call Activity C, but I need return from activity C, so I called Activity C with startActivityForResult and implemented the method onActivityResult in Activity B to get the return.

Everything is working fine, but when activity C finishes, the application is getting back to Activity A, and I need Activity B.

I have to call Activity B explicitly again or I made something wrong?
jonathanrz is offline  
Reply With Quote
Old January 27th, 2012, 12:11 AM   #3 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

I believe if your activity is truly "killed" either by the phone rebooting, or the OS removing it from memory, you will lose the savedInstanceState Bundle

If you need data to persist beyond that, you shoud look at SharedPreferences or other more persistent storage.

Data Storage | Android Developers

As to your second post, in order to stop the back button from going back to "A" you will need to Override the onKeyPress event and capture it so that the OS cannot process it

see here:

is there a default back key(on device) listener in android? - Stack Overflow

hope that helps!
alostpacket is offline  
Reply With Quote
The Following User Says Thank You to alostpacket For This Useful Post:
jonathanrz (January 27th, 2012)
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 12:10 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo