android.bluetooth.BluetoothAdapter#isMultipleAdvertisementSupported ( )源码实例Demo

下面列出了android.bluetooth.BluetoothAdapter#isMultipleAdvertisementSupported ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * コンストラクタ.
 * @param context このインスタンスが属するコンテキスト
 * @throws UnsupportedOperationException BluetoothやBLEがサポートされていない場合に発生
 */
AbstractHOGPServer(final Context context) throws UnsupportedOperationException {
    mApplicationContext = context.getApplicationContext();

    final BluetoothManager btMgr = (BluetoothManager) mApplicationContext.getSystemService(Context.BLUETOOTH_SERVICE);
    final BluetoothAdapter btAdapter = btMgr.getAdapter();
    if (btAdapter == null) {
        throw new UnsupportedOperationException("Bluetooth is not available.");
    }

    if (!btAdapter.isEnabled()) {
        throw new UnsupportedOperationException("Bluetooth is disabled.");
    }

    if (!btAdapter.isMultipleAdvertisementSupported()) {
        throw new UnsupportedOperationException("Bluetooth LE Advertising not supported on this device.");
    }

    mBluetoothLeAdvertiser = btAdapter.getBluetoothLeAdvertiser();
    if (mBluetoothLeAdvertiser == null) {
        throw new UnsupportedOperationException("Bluetooth LE Advertising not supported on this device.");
    }
}
 
private void onBluetoothStateChanged(Context context) {
    // Setup advertiser
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    if (adapter != null) {

        if (!adapter.isEnabled()) {
            Log.w(TAG, "BluetoothLE is disabled");
        }

        if (!adapter.isMultipleAdvertisementSupported()) {
            Log.w(TAG, "Multiple advertisement not supported");
        }

        mAdvertiser = adapter.getBluetoothLeAdvertiser();

        if (mAdvertiser == null) {
            Log.w(TAG, "Device does not support Peripheral Mode");
        }
    } else {
        Log.w(TAG, "Device does not support Bluetooth");
    }

    if (mAdvertiser == null) {
        mIsAdvertising = false;
    }

    if (mShouldStartAdvertising && mAdvertiser != null) {
        startAdvertising(context);
    }
}
 
源代码3 项目: DeviceConnect-Android   文件: BleUtils.java
/**
 * BLEペリフェラルがサポートされているか確認を行います.
 *
 * @param context このアプリケーションが属するコンテキスト
 * @return サポートされている場合はtrue、それ以外はfalse
 */
@SuppressLint("NewApi")
public static boolean isBlePeripheralSupported(@NonNull final Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return false;
    }

    BluetoothAdapter bluetoothAdapter = getAdapter(context);
    return bluetoothAdapter != null && bluetoothAdapter.isMultipleAdvertisementSupported();
}
 
源代码4 项目: AsteroidOSSync   文件: L_Util.java
public static boolean isAdvertisingSupportedByChipset(BluetoothAdapter adapter) {
    return adapter.isMultipleAdvertisementSupported();
}
 
源代码5 项目: SweetBlue   文件: L_Util.java
public static boolean isAdvertisingSupportedByChipset(BluetoothAdapter adapter) {
    return adapter.isMultipleAdvertisementSupported();
}