當前位置: 首頁>>代碼示例>>Java>>正文


Java BluetoothDevice.getType方法代碼示例

本文整理匯總了Java中android.bluetooth.BluetoothDevice.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothDevice.getType方法的具體用法?Java BluetoothDevice.getType怎麽用?Java BluetoothDevice.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.bluetooth.BluetoothDevice的用法示例。


在下文中一共展示了BluetoothDevice.getType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bind

import android.bluetooth.BluetoothDevice; //導入方法依賴的package包/類
@Override public void bind(BluetoothDevice device) {
  nameView.setText(device.getName());
  switch (device.getType()) {
    case DEVICE_TYPE_CLASSIC:
      typeView.setText("DEVICE_TYPE_CLASSIC");
      break;
    case DEVICE_TYPE_DUAL:
      typeView.setText("DEVICE_TYPE_DUAL");
      break;
    case DEVICE_TYPE_LE:
      typeView.setText("DEVICE_TYPE_LE");
      break;
    case DEVICE_TYPE_UNKNOWN:
      typeView.setText("DEVICE_TYPE_UNKNOWN");
      break;
    default:
      typeView.setText("What's this?");
      break;
  }
  addressView.setText(device.getAddress());
  ParcelUuid[] uuids = device.getUuids();
  uuidView.setText(Arrays.toString(uuids));
}
 
開發者ID:shenghaiyang,項目名稱:OkBluetooth,代碼行數:24,代碼來源:DeviceHolder.java

示例2: connect

import android.bluetooth.BluetoothDevice; //導入方法依賴的package包/類
@Override
public synchronized void connect(String address) {
 if (mBluetoothAdapter == null || address == null) {
  NLog.w("BluetoothAdapter not initialized or unspecified address.");
  this.responseMsg(new PenMsg(PenMsgType.PEN_CONNECTION_FAILURE));
  return;
 }

 if (penAddress != null)
 {
  if (this.penStatus == CONN_STATUS_AUTHORIZED)
  {
   responseMsg(new PenMsg(PenMsgType.PEN_ALREADY_CONNECTED));
   return;
  }
  else if (this.penStatus != CONN_STATUS_IDLE)
  {
   return;
  }
 }

    final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
    if (device == null) {
        NLog.w("Device not found.  Unable to connect.");
        this.responseMsg( new PenMsg( PenMsgType.PEN_CONNECTION_FAILURE ) );
        return;
    }

    if ( device.getType() != BluetoothDevice.DEVICE_TYPE_LE )
    {
        NLog.w("MacAddress is not Bluetooth LE Type");
        this.responseMsg( new PenMsg( PenMsgType.PEN_CONNECTION_FAILURE ) );
        return;
    }

 if ( this.penStatus != CONN_STATUS_IDLE ) {
  responseMsg(new PenMsg(PenMsgType.PEN_CONNECTION_FAILURE));
  return;
 }

 this.penAddress = address;
    onConnectionTry();
 responseMsg(new PenMsg(PenMsgType.PEN_CONNECTION_TRY));

    this.penBtName = device.getName();

    this.watchDog = new Timer();
    this.watchDogTask = new TimerTask() {
        @Override
        public void run() {
            watchDogAlreadyCalled = true;
            NLog.d("Run WatchDot : connect failed");
            responseMsg( new PenMsg( PenMsgType.PEN_CONNECTION_FAILURE) );
            onDisconnected();
            close();
        }
    };

    this.watchDogAlreadyCalled = false;
    this.mBluetoothGatt = device.connectGatt(context, false, mBluetoothGattCallback);
 try {
  // schedule이 시작전에 connectGatt가 불려서 Cancel이 되어버리는 경우에 대한 exception처리
  // 커넥션 이후엔 여기에 문제가 생겨도 지장없음.
  this.watchDog.schedule(watchDogTask, 3000);  // 3초
 }
 catch (Exception e)
 {
  e.printStackTrace();
 }
    NLog.d("Trying to create a new connection.");
}
 
開發者ID:NeoSmartpen,項目名稱:AndroidSDK2.0,代碼行數:72,代碼來源:BTLEAdt.java

示例3: onLeScan

import android.bluetooth.BluetoothDevice; //導入方法依賴的package包/類
@Override
public void onLeScan(final BluetoothDevice device, int i, byte[] bytes) {
    if (device.getType() == BluetoothDevice.DEVICE_TYPE_LE) {
        onFind(device);
    }
}
 
開發者ID:e-regular-games,項目名稱:arduator,代碼行數:7,代碼來源:ArduinoCommManagerBle.java

示例4: BLEMeasurementsRecord

import android.bluetooth.BluetoothDevice; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public BLEMeasurementsRecord(List<ScanResult> scanResults) {
    super(new RecordInfo());

    this.deviceCount = scanResults.size();

    this.deviceAddresses = new String[deviceCount];
    this.deviceNames = new String[deviceCount];
    this.rssis = new int[deviceCount];
    this.deviceBondStatuses = new int[deviceCount];
    this.deviceTypes = new int[deviceCount];
    this.timestampsNano = new long[deviceCount];
    this.advertisingSids = new int[deviceCount];
    this.dataStatuses = new int[deviceCount];
    this.periodicAdvertisingIntervals = new int[deviceCount];
    this.primaryPhies = new int[deviceCount];
    this.secondaryPhies = new int[deviceCount];
    this.txPowers = new int[deviceCount];
    this.areConnectable = new boolean[deviceCount];
    this.areLegacy = new boolean[deviceCount];
    this.uuids = new String[deviceCount];
    this.majors = new int[deviceCount];
    this.minors = new int[deviceCount];

    for (int i = 0; i < scanResults.size(); i++) {
        ScanResult scanResult = scanResults.get(i);

        BluetoothDevice bluetoothDevice = scanResult.getDevice();
        this.deviceAddresses[i] = nullStringToEmpty(bluetoothDevice.getAddress());
        this.deviceNames[i] = nullStringToEmpty(bluetoothDevice.getName());
        this.rssis[i] = scanResult.getRssi();
        this.deviceBondStatuses[i] = bluetoothDevice.getBondState();
        this.deviceTypes[i] = bluetoothDevice.getType();
        this.timestampsNano[i] = scanResult.getTimestampNanos();

        this.advertisingSids[i] = getAdvertisingSid(scanResult);
        this.dataStatuses[i] = getDataStatus(scanResult);
        this.periodicAdvertisingIntervals[i] = getPeriodicAdvertisingInterval(scanResult);
        this.primaryPhies[i] = getPrimaryPhy(scanResult);
        this.secondaryPhies[i] = getSecondaryPhy(scanResult);
        this.txPowers[i] = getTxPower(scanResult);
        this.areConnectable[i] = getIsConnectable(scanResult);
        this.areLegacy[i] = getIsLegacy(scanResult);

        byte[] scanRecord = scanResult.getScanRecord().getBytes();
        this.uuids[i] = getUuid(scanRecord);
        this.majors[i] = getMajor(scanRecord);
        this.minors[i] = getMinor(scanRecord);
    }
}
 
開發者ID:ubikgs,項目名稱:AndroidSensors,代碼行數:51,代碼來源:BLEMeasurementsRecord.java


注:本文中的android.bluetooth.BluetoothDevice.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。