Hi I have an app for Android phones.

It is working as intended but when I receive a phone call the app is minimised(but still running) and I have to open the app again.

I was wondering how do I make it so after the phone call it restores my app.

I've found other apps can do this e.g. angry birds but I'm struggling to find examples online.

Recommended Answers

Use PhoneStateLisenter to listen out for changes in the call state, with the onCallStateChanged method.
Once …

Jump to Post

All 2 Replies

Thanks thats exactly how I ended up doing it.

I stored my phones state and compared it to the current phone state to notice a change.

then set set an alarm which triggers my app to open 10 secs later.

here is the code if anyone else gets stuck like I did.

youActivity act = this;
AlarmManager mgr = (AlarmManager)act.getSystemService(Context.ALARM_SERVICE);
RESTART_INTENT = PendingIntent.getActivity(this.getBaseContext(), 0, new Intent(getIntent()), getIntent().getFlags());
if(Globals.lastPhoneState != Globals.telephonyManager.getCallState())
	        mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 10000, RESTART_INTENT);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.