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.

7 Years
Discussion Span
Last Post by ajst

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);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.