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