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


Java BluetoothDevice.createBond方法代码示例

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


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

示例1: createBondDiscoveredDevices

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
private void createBondDiscoveredDevices() {
    Log.d(TAG, "createBondDiscoveredDevices");
    if (mTargetDevices.size() <= 0) {
        Log.d(TAG, "no new discovered device");
        return;
    }
    for (BluetoothDevice device : mTargetDevices) {
        Log.d(TAG, "discovered device:" + device.getName());

        if (device.getBondState() == BluetoothDevice.BOND_BONDED) {
            Log.d(TAG, "already bonded.");
        } else {
            Log.d(TAG, "try to createBond..");
            boolean result = device.createBond();
            Log.d(TAG, "device.createBond() result: " + result);
        }
    }
}
 
开发者ID:casper-kim,项目名称:androidthings-bluetooth-pairing,代码行数:19,代码来源:MainActivity.java

示例2: pair

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
/**
 * Performs the device pairing.
 *
 * @param device the device to pair with.
 * @return true if the pairing was successful, false otherwise.
 */
public boolean pair(BluetoothDevice device) {
    // Stops the discovery and then creates the pairing.
    if (bluetooth.isDiscovering()) {
        Log.d(TAG, "Bluetooth cancelling discovery.");
        bluetooth.cancelDiscovery();
    }
    Log.d(TAG, "Bluetooth bonding with device: " + deviceToString(device));
    boolean outcome = device.createBond();
    Log.d(TAG, "Bounding outcome : " + outcome);

    // If the outcome is true, we are bounding with this device.
    if (outcome == true) {
        this.boundingDevice = device;
    }
    return outcome;
}
 
开发者ID:aurasphere,项目名称:blue-pair,代码行数:23,代码来源:BluetoothController.java

示例3: onReceive

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(BluetoothDevice.ACTION_FOUND)) {
        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        Log.d(TAG, "New Bluetooth device found: " + device.getName() +
                " (" + device.getAddress() + ")");

        if ((device.getName() != null && device.getName().equals(HC05_NAME))
                || device.getAddress().equals(HC05_MAC)) {
            mBluetoothAdapter.cancelDiscovery();
            device.setPin(HC05_PIN);
            device.createBond();
        }
    }
}
 
开发者ID:m-thu,项目名称:android-things,代码行数:16,代码来源:MainActivity.java

示例4: createBond

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private boolean createBond(final BluetoothDevice device) {
    if (device.getBondState() == BluetoothDevice.BOND_BONDED)
        return true;

    boolean result;
    mRequestCompleted = false;

    sendLogBroadcast(LOG_LEVEL_VERBOSE, "Starting pairing...");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        sendLogBroadcast(LOG_LEVEL_DEBUG, "gatt.getDevice().createBond()");
        result = device.createBond();
    } else {
        result = createBondApi18(device);
    }

    // We have to wait until device is bounded
    try {
        synchronized (mLock) {
            while (!mRequestCompleted && !mAborted)
                mLock.wait();
        }
    } catch (final InterruptedException e) {
        loge("Sleeping interrupted", e);
    }

    return result;
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:29,代码来源:DfuBaseService.java

示例5: createBond

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
/**
 * Pair with the specific device.
 */
public boolean createBond(BluetoothDevice device) {
  boolean result = device.createBond();
  Timber.d("Creating bond with: %s/%s/%b", device.getName(), device.getAddress(), result);
  return result;
}
 
开发者ID:zugaldia,项目名称:android-robocar,代码行数:9,代码来源:Nes30Connection.java


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