當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。