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>