Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to READ_PHONE_STATE permission for getting notified of call

Tags:

android

I'm currently using the READ_PHONE_STATE permission in Android to pause my media player when there's a call, and to resume playback when the call is over. The permission seems to scare a lot of people, so I was wondering if there was an alternative to catching the starting and stopping of a phone call without it. Any help is appreciated. Thanks!

like image 401
codeman Avatar asked Jun 23 '14 20:06

codeman


People also ask

What is Call_phone permission?

CALL_PHONE. directly call phone numbers. Allows the app to call phone numbers without your intervention. This may result in unexpected charges or calls.

What is Read_phone_state?

Allows read only access to phone state, including the phone number of the device, current cellular network information, the status of any ongoing calls, and a list of any PhoneAccounts registered on the device. Used to determine the state of the mobile app. Jacob to provide additional details on exact functions. ​


1 Answers

If you want to adjust your audio output in response to something else wanting to perform audio output (e.g., an incoming phone call), look into Android's audio focus support. READ_PHONE_STATE, as noted, is a bit of a scary permission. Moreover, it only deals with phone calls, and not other things that might need the same capability (e.g., VOIP calls, as AFAIK those don't tie into READ_PHONE_STATE-enabled stuff).

like image 183
CommonsWare Avatar answered Oct 05 '22 23:10

CommonsWare