当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothDevice.BOND_BONDING属性代码示例

本文整理汇总了Java中android.bluetooth.BluetoothDevice.BOND_BONDING属性的典型用法代码示例。如果您正苦于以下问题:Java BluetoothDevice.BOND_BONDING属性的具体用法?Java BluetoothDevice.BOND_BONDING怎么用?Java BluetoothDevice.BOND_BONDING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.bluetooth.BluetoothDevice的用法示例。


在下文中一共展示了BluetoothDevice.BOND_BONDING属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performBondStateChangeAction

private void performBondStateChangeAction(Intent intent) {
    final int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
    final int prevState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, BluetoothDevice.ERROR);
    if (state == BluetoothDevice.BOND_BONDED && prevState == BluetoothDevice.BOND_BONDING) {
        showToast(mContext.getString(R.string.device_paired));
        connectToZephyrDevice();
    } else if (state == BluetoothDevice.BOND_NONE) {
        showToast(mContext.getString(R.string.device_pairing_failure));
    }
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:10,代码来源:BluetoothHandler.java

示例2: onReceive

public void onReceive(Context context, Intent intent) {
  String action = intent.getAction();
  // Discovery has found a device.
  if (BluetoothDevice.ACTION_FOUND.equals(action)) {
    // Get the BluetoothDevice object and its info from the Intent.
    BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    int bondState = device.getBondState();
    String foundName = device.getName();
    String foundAddress = device.getAddress(); // MAC address
    Timber.d("Discovery has found a device: %d/%s/%s", bondState, foundName, foundAddress);
    if (isSelectedDevice(foundAddress)) {
      createBond(device);
    } else {
      Timber.d("Unknown device, skipping bond attempt.");
    }
  } else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
    int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1);
    switch (state) {
      case BluetoothDevice.BOND_NONE:
        Timber.d("The remote device is not bonded.");
        break;
      case BluetoothDevice.BOND_BONDING:
        Timber.d("Bonding is in progress with the remote device.");
        break;
      case BluetoothDevice.BOND_BONDED:
        Timber.d("The remote device is bonded.");
        break;
      default:
        Timber.d("Unknown remote device bonding state.");
        break;
    }
  }
}
 
开发者ID:zugaldia,项目名称:android-robocar,代码行数:33,代码来源:Nes30Connection.java

示例3: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
        int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1);

        switch (bondState) {
            case BluetoothDevice.BOND_NONE:
                Log.d(TAG, "Bluetooth device not paired!");
                break;

            case BluetoothDevice.BOND_BONDING:
                Log.d(TAG, "Bluetooth device pairing!");
                break;

            case BluetoothDevice.BOND_BONDED:
                Log.d(TAG, "Bluetooth device paired!");
                break;
        }
    }
}
 
开发者ID:m-thu,项目名称:android-things,代码行数:20,代码来源:MainActivity.java

示例4: onReceive

@Override
public void onReceive(final Context context, final Intent intent) {
    // Obtain the device and check it this is the one that we are connected to
    final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    if (!device.getAddress().equals(mDeviceAddress))
        return;

    // Read bond state
    final int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1);
    if (bondState == BluetoothDevice.BOND_BONDING)
        return;

    mRequestCompleted = true;

    // Notify waiting thread
    synchronized (mLock) {
        mLock.notifyAll();
    }
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:19,代码来源:DfuBaseService.java

示例5: onDevicePairingEnded

/**
 * {@inheritDoc}
 */
@Override
public void onDevicePairingEnded() {
    if (bluetooth.isPairingInProgress()) {
        BluetoothDevice device = bluetooth.getBoundingDevice();
        switch (bluetooth.getPairingDeviceStatus()) {
            case BluetoothDevice.BOND_BONDING:
                // Still pairing, do nothing.
                break;
            case BluetoothDevice.BOND_BONDED:
                // Successfully paired.
                listener.endLoadingWithDialog(false, device);

                // Updates the icon for this element.
                notifyDataSetChanged();
                break;
            case BluetoothDevice.BOND_NONE:
                // Failed pairing.
                listener.endLoadingWithDialog(true, device);
                break;
        }
    }
}
 
开发者ID:aurasphere,项目名称:blue-pair,代码行数:25,代码来源:DeviceRecyclerViewAdapter.java

示例6: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    if (intent.getAction().equals(BluetoothDevice.ACTION_FOUND)) {
        if((mType == TypeBluetooth.Client && !isConnected)
                || (mType == TypeBluetooth.Server && !mAdressListServerWaitingConnection.contains(device.getAddress()))){

            EventBus.getDefault().post(device);
        }
    }
    else if (intent.getAction().equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED))
    {
            //start it up again!
            scanAllBluetoothDevice();
    }
    else if(intent.getAction().equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)){
        //Log.e("", "===> ACTION_BOND_STATE_CHANGED");
        int prevBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, -1);
        int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1);
        if (prevBondState == BluetoothDevice.BOND_BONDING)
        {
            // check for both BONDED and NONE here because in some error cases the bonding fails and we need to fail gracefully.
            if (bondState == BluetoothDevice.BOND_BONDED || bondState == BluetoothDevice.BOND_NONE )
            {
                //Log.e("", "===> BluetoothDevice.BOND_BONDED");
                EventBus.getDefault().post(new BondedDevice());
            }
        }
    }
}
 
开发者ID:n8fr8,项目名称:LittleBitLouder,代码行数:30,代码来源:BluetoothManager.java

示例7: resolveBondingState

/**
 * Resolve bonding state.
 *
 * @param bondState the bond state
 * @return the string
 */
private static String resolveBondingState(final int bondState) {
    switch (bondState) {
        case BluetoothDevice.BOND_BONDED:
            return "Paired";
        case BluetoothDevice.BOND_BONDING:
            return "Pairing";
        case BluetoothDevice.BOND_NONE:
            return "Unbonded";
        default:
            return "Unknown";
    }
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:18,代码来源:BluetoothLeDevice.java

示例8: getState

private String getState(final BluetoothDevice device, final int position) {
	if (mConnectingPosition == position)
		return mConnectingText;
	else if (device.getBondState() == BluetoothDevice.BOND_BONDED)
		return mBondedText;
	else if (device.getBondState() == BluetoothDevice.BOND_BONDING)
		return mBondingText;
	return mAvailableText;
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:9,代码来源:DevicesAdapter.java

示例9: bondStateToString

protected String bondStateToString(final int state) {
	switch (state) {
		case BluetoothDevice.BOND_NONE:
			return "BOND_NONE";
		case BluetoothDevice.BOND_BONDING:
			return "BOND_BONDING";
		case BluetoothDevice.BOND_BONDED:
			return "BOND_BONDED";
		default:
			return "UNKNOWN";
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:12,代码来源:BleManager.java

示例10: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    String action = intent.getAction();
    BluetoothDevice device = null;
    device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    if(device!=null){
    }
    if (BluetoothDevice.ACTION_FOUND.equals(action)) {
        if (device.getBondState() == BluetoothDevice.BOND_NONE) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("name", device.getName());
            map.put("type", device.getBluetoothClass().getDeviceClass());
            map.put("device", device);
            if (list.indexOf(map) == -1) {// 防止重复添加
                list.add(map);
                itemAdapter = new MyBluetoothAdapter(context, list);
                searchDeviceLV.setAdapter(itemAdapter);
            }
        }
    } else if (device != null && device.getBondState() == BluetoothDevice.BOND_BONDING) {
        showShortToast("Being paired");
    } else if (device != null && device.getBondState() == BluetoothDevice.BOND_BONDED) {
        pairTVName.setText(device.getName());
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).get("device").equals(device)) {
                pairPosition = i;
                list.remove(i);
                itemAdapter.notifyDataSetChanged();
            }
        }
        showShortToast("Pairing is complete");
    }
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:34,代码来源:Bluetooth.java

示例11: getPairingDeviceStatus

/**
 * Returns the status of the current pairing and cleans up the state if the pairing is done.
 *
 * @return the current pairing status.
 * @see BluetoothDevice#getBondState()
 */
public int getPairingDeviceStatus() {
    if (this.boundingDevice == null) {
        throw new IllegalStateException("No device currently bounding");
    }
    int bondState = this.boundingDevice.getBondState();
    // If the new state is not BOND_BONDING, the pairing is finished, cleans up the state.
    if (bondState != BluetoothDevice.BOND_BONDING) {
        this.boundingDevice = null;
    }
    return bondState;
}
 
开发者ID:aurasphere,项目名称:blue-pair,代码行数:17,代码来源:BluetoothController.java

示例12: handleMessage

@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case Comment.SWITCH:
            switch ((int) msg.obj) {
                case BluetoothAdapter.STATE_OFF:
                    nonebound_tv.setText("可用设备(" + DatasEntity.mBluetoothDevices.size() + ")");
                    btnSearch.setChecked(false);
                    clearAdapter();
                    break;
                case BluetoothAdapter.STATE_ON:
                    reswipeAdapter();
                    break;
            }
            break;
        case Comment.FOUND:
            DatasEntity.mBluetoothDevices.add((BluetoothDevice) msg.obj); // 添加到列表
            nonebound_tv.setText("可用设备(" + DatasEntity.mBluetoothDevices.size() + ")");
            mGetarrayAdapter.notifyDataSetChanged();
            ListViewHeightMesure.setAdapterHeight(mLvallDevices);
            break;

        case Comment.FINISHED:
            setTitle("玩蓝牙");
            rotate_img.clearAnimation();
            break;

        case Comment.BOND:
            switch ((int) msg.obj) {
                case BluetoothDevice.BOND_BONDING://正在配对
                    DialogUtil.ShowProgress(MainActivity.this, "配对中...");
                    break;
                case BluetoothDevice.BOND_BONDED://配对结束
                    DialogUtil.CancelProgress();
                    clearAdapter();
                    reswipeAdapter();
                    ToastUtil.showShort(MainActivity.this,"连接中...");
                    BluetoothUtil.connectSocket(mHandler);
                    break;
                case BluetoothDevice.BOND_NONE://取消配对/未配对
                    ToastUtil.showShort(MainActivity.this, "已取消配对");
                    break;
            }
            break;
        case Comment.CONNECT:
            ToastUtil.showShort(MainActivity.this,"连接成功!");
            break;

    }
}
 
开发者ID:aiyangtianci,项目名称:BluetoothAPP,代码行数:50,代码来源:MainActivity.java


注:本文中的android.bluetooth.BluetoothDevice.BOND_BONDING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。