I am developing an app and have been able to start a phone call inside the app but when it end I want to resume the app with the information preserved and a pop up to come up.
I have been able to dial the call and get the pop up to come up in seperate instances but unable to put them together. This question has been answered in March of this year but I wanted to see if anyone else has come up with a better idea. Thank you.
Looking at the Activity Life cycle diagram, when a phone call is received application calls
onPause()method. What I can think of is for you to do a saving of your data usingSharedPreferenceswriting data from a thread which will run regardless if the application is not visible anymore to the user, either you do this in the call listener or inonPause()method. But more practical approach is to useonSaveInstanceState()method where you put all the relevant data which will be restored lately inonRestoreInstanceState()method.Read more here how they work:
http://developer.android.com/reference/android/app/Activity.html#onRestoreInstanceState(android.os.Bundle)
http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle)
http://developer.android.com/reference/android/telephony/PhoneStateListener.html
In the
PhoneStateListenerclass you can use someflagsto mark if the call has taken place, when going toCALL_STATE_RINGINGstate, and then in theCALL_STATE_IDLEcheck whether call is made because IDLE state is occuring all the time when the phone is doing nothing, but when you have a flag you can checkif(flag)do something and change the flag, so whenever the listener is again inCALL_STATE_IDLEyour flag will be inverted so no actions again will be taken. Just an idea.Edit: Add the the PhoneStateListener class as inner class in your activity/service class and register phone state listener using
TelephonyManager. I hope you’ll find your way