How to monitor out going calls

Quickly share your Android Code Snippets here...

How to monitor out going calls

Postby Draffodx » Tue Jan 05, 2010 6:02 pm

Here is a piece of code that listens for an outgoing call, the code then takes the number that was being called, blocks the outgoing call and I then add a Call Log entry to the call Log via the Call Log content provider.

Its not very useful as is but can be used for example to stop a call when roaming and add the required prefix for ringing internationally

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void monitorOutgoingCalls(){
  2.  
  3.                
  4.  
  5.                  callRcv = new BroadcastReceiver(){
  6.  
  7.                         public void onReceive(Context context, Intent intent) {
  8.  
  9.                                 String action = intent.getAction();
  10.  
  11.                             if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {
  12.  
  13.                                 String number = getResultData();
  14.  
  15.                                 setResultData(null);
  16.  
  17.                                 Log.d("CALL MONITOR", "Outgoing call logged");
  18.  
  19.                                 addCall(number, "2", 0);
  20.  
  21.                                
  22.  
  23.                             }
  24.  
  25.  
  26.  
  27.                         }
  28.  
  29.                          
  30.  
  31.                  };
  32.  
  33.                  
  34.  
  35.                  registerReceiver(callRcv, new IntentFilter(Intent.ACTION_NEW_OUTGOING_CALL));
  36.  
  37.                  
  38.  
  39.          }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Re: How to monitor out going calls

Postby t0mm13b » Sun Dec 05, 2010 11:34 pm

May I ask what's the addCall function doing?
t0mm13b
Freshman
Freshman
 
Posts: 2
Joined: Wed Oct 13, 2010 9:43 pm

Re: How to monitor out going calls

Postby blundell » Mon Dec 06, 2010 12:49 pm

Nice, would be good if you could attach an example project for people to see where they would declare the class etc
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: How to monitor out going calls

Postby suninbangalore » Wed Apr 06, 2011 8:44 am

Hi! Draffodx

Finally! I found something here to help myself.. Basically I am trying something similar which I plan to extend later..

Your code snippet does give some insight on monitoring out Going Calls.. but it would be helpful if you could include a few lines on how to go about creating the project for such a use case..

I've only tried a "Activities" - no idea about Intents!

Thanks for your help!
-sunil-
suninbangalore
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Apr 06, 2011 8:14 am

Re: How to monitor out going calls

Postby Mike.Adams » Wed Apr 06, 2011 4:55 pm

thanks for the share!
Hi I'm Mike. Checkout my source code, projects and work here and let me know what you think.

Feel free to also upload and submit your code/projects there for all to see and find!
Mike.Adams
Developer
Developer
 
Posts: 26
Joined: Mon Mar 07, 2011 9:19 pm
Location: New York

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 3 guests