Lior Ohana
Lior Ohana

Reputation: 3527

How to know whether my activity was resumed after an incoming call

At first, it sound like a simple thing to do but I found it no so simple. What I'm trying to achieve is to have my android app return to a certain state after an it went to the background upon an incoming call.

The question is, what is the best way to know whether my app went to foreground after the user rejected or ended an incoming call (that occurred while my app was in the foreground)?

I know I can use broadcast receivers to identify incoming calls.

Thanks.

Upvotes: 0

Views: 2953

Answers (2)

Konstantin Pribluda
Konstantin Pribluda

Reputation: 12367

Basically you can trust Android to reactivate your activity from background and call onResume() method. When your activity is about to be put to background, onPause() will be called ( and this is only reliable callback )

Upvotes: 0

PravinCG
PravinCG

Reputation: 7708

You should look at Activity Lifecycle

Once you app is resumed/restarted onResume/onRestart would be called, you do not need to listen for broadcast unless you are doing something with audio that will hamper the ongoing call.

Upvotes: 1

Related Questions