Code example for Messenger

0
                    super.handleMessage(msg);
            } 
        } 
    } 
 
    final Messenger mMessenger = new Messenger(new IncomingHandler());
 
    /** 
     * Make sure Bluetooth and health profile are available on the Android device.  Stop service 
     * if they are not available. 
     */ 
    @Override 
    public void onCreate() { 
        super.onCreate(); 
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
            // Bluetooth adapter isn't available.  The client of the service is supposed to 
            // verify that it is available and activate before invoking this service. 
            stopSelf();
            return; 
        }