Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: What happens to my activity in case of incoming phone call?

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..!

like image 966
Pria Avatar asked Mar 12 '10 06:03

Pria


People also ask

When can Android activity be destroyed?

The Activity lifecycle is especially important because whenever an activity leaves the screen, the activity can be destroyed. When an activity is destroyed, when the user returns to the activity, the activity will be re-created and the lifecycle methods will be called again.

How do you make a phone call in Android and come back to my activity when the call is done?

finish(); at the end of activity. It will redirect you to your previous activity. Save this answer.

What do you mean by Android activity?

An activity provides the window in which the app draws its UI. This window typically fills the screen, but may be smaller than the screen and float on top of other windows. Generally, one activity implements one screen in an app.


2 Answers

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

like image 176
Janusz Avatar answered Nov 15 '22 10:11

Janusz


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

like image 41
Sephy Avatar answered Nov 15 '22 12:11

Sephy