0

I know, this may seem alike a "trivial" question, but there is a bit of confusion since there are multiple options available.

I want to listen to phone calls and have found two solutions for doing the same:

These seem to be mutually exclusive. What solution should I prefer? Do they really cater to different use cases? If so, what might they be?

Manish Kumar Sharma
  • 12,982
  • 9
  • 58
  • 105

1 Answers1

1

If you use a BroadcastReceiver your application does not need to be running. Android broadcasts call-related events and your BroadcastReceiver will be notified of call-related events and you can do whatever you want to do.

If you use a PhoneStateListener, your application must be running. You will need an Activity or a Service that creates the PhoneStateListener and registers it. Your PhoneStateListener will then be notified of call-related events. When your app is finished or killed by Android you will no longer receive any call-related events.

David Wasser
  • 93,459
  • 16
  • 209
  • 274