예제 #1
0
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

          if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            // ... //Device found
          } else if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
            // Device is now connected
            PrintHelper.SetIsConnected(true);
            AppGlobals.printerTestDialogFragment.SetPrinterStatus();
          } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
            // Done searching
          } else if (BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED.equals(action)) {
            // Device is about to disconnect
          } else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) {
            // Device has disconnected
            PrintHelper.SetIsConnected(false);
            AppGlobals.printerTestDialogFragment.SetPrinterStatus();
          }
        }