Code example for Handler

Methods: sendMessage, obtain

0
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mHandler = h;
    } 
 
    private void sendMessage(int message, int arg, Object obj) {
        Message m = Message.obtain(mHandler, message);
        m.arg1 = arg;
        m.obj = obj;
        mHandler.sendMessage(m);
    } 
 
    private void handleFailedConnection() { 
        if (getServiceState() != STATE_NONE) {
            if (D) Log.d(TAG, "Connection failed with status != 0. try to reconnect");
            connect(lastConnectedDevice);
        } else { 
            if (D) Log.d(TAG, "Connection stopped with status = 0.");
        } 
    } 
 
    /**