Want more features on Pastebin? Sign Up, it's FREE!
Guest

call content observer

By: moonlightcheese on Sep 28th, 2011  |  syntax: Java  |  size: 0.84 KB  |  views: 700  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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));
clone this paste RAW Paste Data