currently, is call intercept on android possible? to a level where i can get the phone number when a call is made.
yes you can .... extend BroadcastReceiver and override onReceive as the following
public class CallListener extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
String phoneNumber = intent.getExtras().getString(Intent.EXTRA_PHONE_NUMBER);
System.out.println(phoneNumber);
if (phoneNumber != null&& CallService.phoneNumber.equals("ANY_NUMBER_YOU_WANNA_INTERCEPT_ON")) {
//do what you want to do :)
}
}
}
and you will need to add your BroadcastReceiver on the AndroidManifest.xml as the following
<receiver android:name=".CallListener" android:permission="android.permission.PROCESS_OUTGOING_CALLS">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
You can use PhoneStateListener with a custom broadcast receiver, which gets you onCallStateChanged(int state, String incomingNumber)
.
(You'll also need <uses-permission android:name="android.permission.READ_PHONE_STATE" />
in your AndroidManifest.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With