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


Java BluetoothAdapter.disable方法代码示例

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


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

示例1: SetNewBluetoothState

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
public void SetNewBluetoothState(boolean isEnabled) {
    Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "SetNewBluetoothState: %s", isEnabled));
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (isEnabled) {
        if (IsBluetoothEnabled()) {
            Logger.getInstance().Information(TAG, "BT already enabled!");
            return;
        }
        bluetoothAdapter.enable();
    } else {
        if (!IsBluetoothEnabled()) {
            Logger.getInstance().Information(TAG, "BT already disabled!");
            return;
        }
        bluetoothAdapter.disable();
    }
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:18,代码来源:BluetoothController.java

示例2: setBluetooth

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
public void setBluetooth(Context context, int resId) {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter == null) {
        displayNotification(context, "Unable to get BluetoothAdapter");
        return;
    }


    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String value = prefs.getString(context.getString(resId), "unset");
    if (value.equalsIgnoreCase("Enable")) {
        Log.i("StartBluetooth", "enabling bluetooth");
        bluetoothAdapter.enable();
    } else if (value.equalsIgnoreCase("Disable")) {
        Log.i("StartBluetooth", "disabling bluetooth");
        bluetoothAdapter.disable();
    }

}
 
开发者ID:Eun,项目名称:StartBluetooth,代码行数:20,代码来源:Service.java

示例3: changeBluetoothState

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
private static void changeBluetoothState(Intent intent) {
    try {
        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
        int labelResId;
        if (intent.hasExtra(AShortcut.EXTRA_ENABLE)) {
            if (intent.getBooleanExtra(AShortcut.EXTRA_ENABLE, false)) {
                btAdapter.enable();
                labelResId = R.string.bluetooth_on;
            } else {
                btAdapter.disable();
                labelResId = R.string.bluetooth_off;
            }
        } else {
            if (btAdapter.isEnabled()) {
                labelResId = R.string.bluetooth_off;
                btAdapter.disable();
            } else {
                btAdapter.enable();
                labelResId = R.string.bluetooth_on;
            }
        }
        if (intent.getBooleanExtra(AShortcut.EXTRA_SHOW_TOAST, false)) {
            Utils.postToast(mContext, labelResId);
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:29,代码来源:ConnectivityServiceWrapper.java

示例4: setBluetooth

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
public static boolean setBluetooth(boolean enable) {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    boolean isEnabled = bluetoothAdapter.isEnabled();
    if (enable && !isEnabled) {
        isBluetoothOn = true;
        return bluetoothAdapter.enable();
    }
    else if(!enable && isEnabled) {
        isBluetoothOn = false;
        return bluetoothAdapter.disable();
    }
    // No need to change bluetooth state
    return true;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:15,代码来源:Utilities.java


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