Code example for Messenger

0
    } 
     
    /** 
     * Target we publish for clients to send messages to IncomingHandler. 
     */ 
    final Messenger mMessenger = new Messenger(new IncomingHandler());
     
    @Override 
    public void onCreate() { 
        mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
 
        // Display a notification about us starting. 
        showNotification(); 
    } 
 
    @Override 
    public void onDestroy() { 
        // Cancel the persistent notification. 
        mNM.cancel(R.string.remote_service_started);
 
        // Tell the user we stopped.