Reputation: 11
I'm working on making an app that prevents the user from calling certain contacts. I have the contacts in a database but I don't know where to go after that. I know that I must use a broadcast receiver and permission in the manifest but other than that I'm stuck.
Upvotes: 1
Views: 2554
Reputation:
Well, if device goes into "Airplane Mode", then obviously Telephony services will not function. Once in your BroadcastReceiver you receive NEW_OUTGOING_CALL intent, make your device to go into "Airplane mode". There exist is an Intent to do that, and of course your app needs to have necessary permission also to change mode of device to Airplane mode. App also needs to bring back device into working mode once "Block" operation is finished.
Upvotes: 0
Reputation: 33034
This explains how to do it: http://groups.google.com/group/android-developers/browse_thread/thread/931e04811839326e
The gist is that you need to use a BroadcastReciever
to intercept the NEW_OUTGOING_CALL
intent, but making sure to set the priority of your intent filter to -1. To abort the outbound call, you'll need to call setResultData(null);
before returning from BroadcastReceiver.onReceive(Context, Intent)
(which prevents downstream handlers of the intent from processing the outbound call).
Upvotes: 5