currently, is call intercept on android possible? to a level where i can get the phone number when a call is made.
Asked
Active
Viewed 5,561 times
2 Answers
4
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>

M_G
- 1,208
- 1
- 11
- 16

shereifhawary
- 463
- 4
- 13
1
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.)

Ben Williams
- 6,027
- 2
- 30
- 54
-
Thanks Ben Williams, I want to get the number when a user make a call. the number where a call is made too. – shebelaw May 04 '11 at 14:49
-
I'm not sure you can directly, but if you're listening for phone state changes, you should be able to tell when a call went out and ended, and then immediately `CallLog.Calls` and `getLastOutgoingCall` gives you the last called number. – Ben Williams May 04 '11 at 14:59
-
tanks again. I will take a look in to that. But what I really want is to get the number while the call is active or when the call button is tabbed. – shebelaw May 04 '11 at 16:54