Пример #1
0
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          Log.d(TAG, "进入广播:" + action.toString());

          // 发现设备
          if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            Log.d(TAG, "发现设备");
            devices.add(device.getName() + "\n" + device.getAddress());
            Log.d(TAG, "devices:" + device.getName() + "[" + device.getAddress() + "]");

            // 添加非配对设备
            if (isLock(device)) {
              String address = device.getAddress();

              devices.add(device.getName() + "\n" + device.getAddress());
              Log.d(TAG, "devices" + devices);
              deviceList.add(device);
              Log.d(TAG, "deviceList" + deviceList);
              Log.d(TAG, "address" + address);
              device1 = adapter.getRemoteDevice(address);
              Log.d(TAG, "device1:" + device1);
              blueclient.nativeInit(device);
            }
          }
        }
Пример #2
0
  public boolean isConnected() {

    return blueclient.isConnected();
  }
Пример #3
0
 public void stop() {
   // TODO Auto-generated method stub
   blueclient.stop();
 }
Пример #4
0
 public void sendMessage() {
   blueclient.sendmsg(0, 0);
 }