En AndroidManifest.xml que shoud hacer un receptor:
<receiver android:name="IncomingCallInterceptor">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
y declara el permiso:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Entonces,
public class IncomingCallInterceptor extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
// Phone is ringing
}
}
}
está funcionando bien. Pero dos veces transmitiendo –