views:

230

answers:

3

I want to know that what will happen to my activity incase of an incoming phone call? Will the state of my activity be saved or I have to explicitly save it?

Another question is that will the activity resume after the call is disconnected?

Please help..!

+1  A: 

you can try that on the emulator by connecting another emulator and call the first one with it. Actually yes, your activity will be saved, and reload the phone call will stop. I'll try to find some doc for you. wait a few min plz

life cycle of an activity here

Sephy
Yes, I tried it on emulator. The activity gets saved. Thanks.
Pria
If you have the answer, please validate the topic, this makes us earn points if our answers have helped you.thanks
Sephy
+2  A: 

You can test the behavior of your app through switching between portrait and landscape modus (CONTROL + F11 in the emulator). This will close your activity and then after the screen orientation is switched the activity is recreated.

Simple things will be saved, but some things like the position of your cursor, or user input to text fields won't be saved. You can do this yourself in the onSaveInstanceState() method from your Activity. Read more here

Janusz
When my app is getting interrupted by a call and getting resumed, at that time, the state is getting saved. But, when I use the orientation change test, the value in text view is not getting saved. Can u please explain why it is so?
Pria
There is a difference in the lifecycle handling. If you are called your app is paused and your view is still active and in memory. If you switch the orientation the view has to be rebuild that is the same thing as what happens if your users sends the app in the background, you app will not be paused but stopped.Checkout the notepad example (http://developer.android.com/intl/fr/guide/tutorials/notepad/notepad-ex1.html) for more details on lifecycle handling
Janusz
Ok..got it..Thanks a lot!
Pria
A: 

I validated it on the emulator by creating an incoming call on my emulator. To do this I used the emulator console and used the gsm call option.

The values in my textview are saved on resume.

Thanks a lot for ur replies!

Pria