Advertisement
moonlightcheese

call content observer

Sep 28th, 2011
1,405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. private class RatedCallsContentObserver extends ContentObserver {
  2.     Handler mHandler;
  3.    
  4.     public RatedCallsContentObserver(Handler h) {
  5.         super(h);
  6.         mHandler = h;
  7.     }
  8.    
  9.     @Override
  10.     public boolean deliverSelfNotifications() {
  11.         return true;
  12.     }
  13.    
  14.     @Override
  15.     public void onChange(boolean selfChange) {
  16.         //here is where you handle the call log change
  17.         //it may be a good idea to ensure that the call log application is already running before bringing your app to the foreground
  18.         //to ensure it is displayed on top of the call log app
  19.        
  20.         super.onChange(selfChange);
  21.     }
  22. }
  23.  
  24.  
  25. //later in the Service, attach the appropriate content URI to an instance of our observer
  26. this.getApplicationContext().getContentResolver().registerContentObserver(android.provider.CallLog.Calls.CONTENT_URI, true, new RatedCallsContentObserver(internalHandler));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement