Java Code Examples for android.content.Intent#ACTION_NEW_OUTGOING_CALL

The following examples show how to use android.content.Intent#ACTION_NEW_OUTGOING_CALL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AudioManager.java    From QuranAndroid with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Broadcast receiver to check outgoing call
 */
private void initOutgoingBroadcastReceiver() {
    OutgoingBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {

            if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {

                isInCall = true;

                if (isInCall == true) {
                    smallMediaPlayer = SmallMediaPlayer.getInstance(context);
                    bigNotification = false;
                    pauseMedia();
                }

            }
        }
    };
    IntentFilter filter = new IntentFilter(Intent.ACTION_NEW_OUTGOING_CALL);
    context.registerReceiver(OutgoingBroadcastReceiver, filter);
}
 
Example 2
Source File: OutgoingCallReceiverTest.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void activityShouldGetCorrectIntentData() {
    // prepare data for onReceive and call it
    Intent intent = new Intent(Intent.ACTION_NEW_OUTGOING_CALL);
    intent.putExtra(Intent.EXTRA_PHONE_NUMBER, "01234567890");

    mReceiver.onReceive(mContext, intent);
    assertNull(mReceiver.getResultData());

    // what did receiver do?
    verify(mContext, times(1)).startActivity(captor.capture());
    Intent receivedIntent = captor.getValue();
    assertNull(receivedIntent.getAction());
    assertEquals("01234567890", receivedIntent.getStringExtra("phoneNum"));
    assertTrue((receivedIntent.getFlags() &
            Intent.FLAG_ACTIVITY_NEW_TASK) != 0);
}