pixelscreen pixelscreen - 2 years ago 195
Android Question

Small confusion about PhoneStateIntentReceiver

public class MyReceiver extends PhoneStateIntentReceiver {
public void onReceiveIntent(Context context, Intent intent) {
if (intent.action == Intent.CALL_ACTION) {


Assume that notifyPhoneCallState has been called to enable MyReceiver to receive notifications about phone call states, in which case the code will get executed?

  • when device receives an incoming call

  • when outgoing call is initiated on the device

  • when the user presses the call button

  • incoming phone call is terminated

  • or will the code not be executed at all?

Answer Source

Did you mean public static final String ACTION_CALL instead of CALL_ACTION?

Activity Action: Perform a call to someone specified by the data.

Input: If nothing, an empty dialer is started; else getData() is URI of a phone number to be dialed or a tel: URI of an explicit phone number.

Output: nothing.

Note: there will be restrictions on which applications can initiate a call; most applications should use the ACTION_DIAL.

Note: this Intent cannot be used to call emergency numbers. Applications can dial emergency numbers using ACTION_DIAL, however.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download