0

Please tell me what am I doing wrong?

The BroacastReceiver is supposed to listen to incoming and outgoing phone calls.

Here is the receiver:

public class CallReceiver extends PhonecallReceiver {

    @Override
    protected void onIncomingCallStarted(String number, Date start) {
        Log.e("CyranoActivty","disableBluetooth");
        BluetoothManager.stopBluetooth();
    }

    @Override
    protected void onOutgoingCallStarted(String number, Date start) {
        Log.e("CyranoActivty","disableBluetooth");
        BluetoothManager.stopBluetooth();
    }

    @Override
    protected void onIncomingCallEnded(String number, Date start, Date end) {
        Log.e("CyranoActivty","enableBluetooth");
        BluetoothManager.restartBluetooth();
    }

    @Override
    protected void onOutgoingCallEnded(String number, Date start, Date end) {
        Log.e("CyranoActivty","enableBluetooth");
        BluetoothManager.restartBluetooth();
    }

    @Override
    protected void onMissedCall(String number, Date start) {
    }

}

here link to the superclass of CallReceiver

The receiver is registered in onCreate() of the Activity

phonecallreceiver = new CallReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction("android.intent.action.PHONE_STATE");
    filter.addAction("android.intent.action.NEW_OUTGOING_CALL");
    registerReceiver(phonecallreceiver, filter); 

Here is my Manifest:

     <activity
        android:name="com.cjcornell.samplebluetooth.CyranoActivity"
        android:label="@string/title_activity_cyrano" >
        <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>
    </activity>
Community
  • 1
  • 1
Lisa Anne
  • 4,482
  • 17
  • 83
  • 157
  • I wonder why do you include **BroadcastReceiver**'s intent-filters inside **Activity** declaration in manifest? – waqaslam Jun 08 '14 at 00:46

1 Answers1

2

Be sure to set the correct permissions in the manifest as well.

ImmortalDev
  • 476
  • 3
  • 5