Code example for Messenger

    private class HgServiceConnection extends Handler implements ServiceConnection {
        Messenger serviceMessenger = null;
        Messenger responseMessenger = new Messenger(this);
        private WeakReference<ServiceBinder> sb;
        public HgServiceConnection(Looper looper, ServiceBinder sb){
   = new WeakReference<ServiceBinder>(sb);
        public void onServiceConnected(ComponentName className, IBinder service) {
	        //service has been connected to this, send the given message 
	        serviceMessenger = new Messenger(service);
Connect your IDE to all the code out there  Get Codota for Java