當前位置: 首頁>>代碼示例>>Java>>正文


Java BluetoothAdapter.STATE_TURNING_OFF屬性代碼示例

本文整理匯總了Java中android.bluetooth.BluetoothAdapter.STATE_TURNING_OFF屬性的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothAdapter.STATE_TURNING_OFF屬性的具體用法?Java BluetoothAdapter.STATE_TURNING_OFF怎麽用?Java BluetoothAdapter.STATE_TURNING_OFF使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.bluetooth.BluetoothAdapter的用法示例。


在下文中一共展示了BluetoothAdapter.STATE_TURNING_OFF屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: btEnable

@Rpc(description = "Enable bluetooth with a 30s timeout.")
public void btEnable() throws BluetoothAdapterSnippetException, InterruptedException {
    if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
        return;
    }
    // If bt is trying to turn off, wait for that to finish before continuing.
    if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_TURNING_OFF) {
        if (!Utils.waitUntil(
                () -> mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF,
                TIMEOUT_TOGGLE_STATE)) {
            Log.e(String.format("BT failed to stabilize after %ss.", TIMEOUT_TOGGLE_STATE));
        }
    }
    if (!mBluetoothAdapter.enable()) {
        throw new BluetoothAdapterSnippetException("Failed to start enabling bluetooth");
    }
    if (!Utils.waitUntil(() -> mBluetoothAdapter.isEnabled(), TIMEOUT_TOGGLE_STATE)) {
        throw new BluetoothAdapterSnippetException(
                String.format("Bluetooth did not turn on within %ss.", TIMEOUT_TOGGLE_STATE));
    }
}
 
開發者ID:google,項目名稱:mobly-bundled-snippets,代碼行數:21,代碼來源:BluetoothAdapterSnippet.java

示例2: BluetoothControl20

public BluetoothControl20() {
	// cache adaptor
	mAdapter = BluetoothAdapter.getDefaultAdapter();

	if (mAdapter == null) throw new UnsupportedOperationException("No default bluetooth adapter");
	
	// initialize state
 BLUETOOTH_STATE_UNKNOWN = -1;
 BLUETOOTH_STATE_OFF = BluetoothAdapter.STATE_OFF;
 BLUETOOTH_STATE_TURNING_ON = BluetoothAdapter.STATE_TURNING_ON;
 BLUETOOTH_STATE_ON = BluetoothAdapter.STATE_ON;
 BLUETOOTH_STATE_TURNING_OFF = BluetoothAdapter.STATE_TURNING_OFF;
 
 BLUETOOTH_ACTION_STATE_CHANGED = BluetoothAdapter.ACTION_STATE_CHANGED;
 BLUETOOTH_EXTRA_STATE = BluetoothAdapter.EXTRA_STATE;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:16,代碼來源:BluetoothSettingHandler.java

示例3: handleUpdateState

@Override
public void handleUpdateState(Object state, Object arg) {
    mState.visible = true;
    mState.booleanValue = false;

    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

    int btState = adapter == null ? BluetoothAdapter.ERROR : adapter.getState();
    if (isInErrorState(btState)) {
        mState.label = mGbContext.getString(R.string.qs_tile_bt_tethering_error);
        mState.icon = mGbContext.getDrawable(R.drawable.ic_qs_bt_tethering_off);
    } else if (btState == BluetoothAdapter.STATE_TURNING_ON ||
            btState == BluetoothAdapter.STATE_TURNING_OFF) {
        mState.label = "---";
        mState.icon = mGbContext.getDrawable(R.drawable.ic_qs_bt_tethering_off);
    } else if (btState == BluetoothAdapter.STATE_ON && isTetheringOn()) {
        mState.label = mGbContext.getString(R.string.qs_tile_bt_tethering_on);
        mState.icon = mGbContext.getDrawable(R.drawable.ic_qs_bt_tethering_on);
        mState.booleanValue = true;
    } else {
        mState.label = mGbContext.getString(R.string.qs_tile_bt_tethering_off);
        mState.icon = mGbContext.getDrawable(R.drawable.ic_qs_bt_tethering_off);
    }

    super.handleUpdateState(state, arg);
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:26,代碼來源:BluetoothTetheringTile.java

示例4: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();

    if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
        final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
        switch (state) {
            case BluetoothAdapter.STATE_OFF:
            case BluetoothAdapter.STATE_TURNING_OFF:
            case BluetoothAdapter.STATE_TURNING_ON:
                stopBluetooth();
                break;
            case BluetoothAdapter.STATE_ON:
                startBluetooth();
                break;
        }
    }
}
 
開發者ID:RomascuAndrei,項目名稱:BTNotifierAndroid,代碼行數:18,代碼來源:Server.java

示例5: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case BluetoothAdapter.ACTION_STATE_CHANGED:
            int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
            switch (state) {
                case BluetoothAdapter.STATE_TURNING_ON:// 藍牙打開中

                    break;
                case BluetoothAdapter.STATE_ON:// 藍牙打開完成

                    break;
                case BluetoothAdapter.STATE_TURNING_OFF:// 藍牙關閉中

                    break;
                case BluetoothAdapter.STATE_OFF:// 藍牙關閉完成

                    break;
                default:
                    break;
            }
        default:
            break;
    }
}
 
開發者ID:RockyQu,項目名稱:BluetoothKit,代碼行數:25,代碼來源:BluetoothReceiver.java

示例6: onReceive

@Override
public void onReceive(Context context, Intent intent) {
	Log.d(LOG_TAG, "onReceive");
	final String action = intent.getAction();

	String stringState = "";
	if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
		final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
				BluetoothAdapter.ERROR);
		switch (state) {
			case BluetoothAdapter.STATE_OFF:
				stringState = "off";
				break;
			case BluetoothAdapter.STATE_TURNING_OFF:
				stringState = "turning_off";
				break;
			case BluetoothAdapter.STATE_ON:
				stringState = "on";
				break;
			case BluetoothAdapter.STATE_TURNING_ON:
				stringState = "turning_on";
				break;
		}
	}

	WritableMap map = Arguments.createMap();
	map.putString("state", stringState);
	Log.d(LOG_TAG, "state: " + stringState);
	sendEvent("BleManagerDidUpdateState", map);
}
 
開發者ID:lenglengiOS,項目名稱:react-native-blue-manager,代碼行數:30,代碼來源:BleManager.java

示例7: stateToString

/**
 * Converts BluetoothAdapter states into local string representations.
 */
private String stateToString(int state) {
    switch (state) {
        case BluetoothAdapter.STATE_DISCONNECTED:
            return "DISCONNECTED";
        case BluetoothAdapter.STATE_CONNECTED:
            return "CONNECTED";
        case BluetoothAdapter.STATE_CONNECTING:
            return "CONNECTING";
        case BluetoothAdapter.STATE_DISCONNECTING:
            return "DISCONNECTING";
        case BluetoothAdapter.STATE_OFF:
            return "OFF";
        case BluetoothAdapter.STATE_ON:
            return "ON";
        case BluetoothAdapter.STATE_TURNING_OFF:
            // Indicates the local Bluetooth adapter is turning off. Local clients should immediately
            // attempt graceful disconnection of any remote links.
            return "TURNING_OFF";
        case BluetoothAdapter.STATE_TURNING_ON:
            // Indicates the local Bluetooth adapter is turning on. However local clients should wait
            // for STATE_ON before attempting to use the adapter.
            return "TURNING_ON";
        default:
            return "INVALID";
    }
}
 
開發者ID:nhancv,項目名稱:nc-android-webrtcpeer,代碼行數:29,代碼來源:BluetoothManager.java

示例8: newStateDetected

private void newStateDetected(int state) {
    bluetoothState = state;
    switch (state) {
        case BluetoothAdapter.STATE_OFF:
            //Indicates the local Bluetooth adapter is off.
            break;

        case BluetoothAdapter.STATE_TURNING_ON:
            //Indicates the local Bluetooth adapter is turning on. However local clients should wait for STATE_ON before attempting to use the adapter.
            break;

        case BluetoothAdapter.STATE_ON:
            //Indicates the local Bluetooth adapter is on, and ready for use.
            break;

        case BluetoothAdapter.STATE_TURNING_OFF:
            if (!Pandwarf.getInstance().isConnected()) {
                return;
            }
            killAllProcess(new GollumCallbackGetBoolean() {
                @Override
                public void done(boolean b) {
                    EventBus.getDefault().postSticky(new StateEvent(DISCONNECTED, ""));
                }
            });
            //Indicates the local Bluetooth adapter is turning off. Local clients should immediately attempt graceful disconnection of any remote links.
            break;
    }
}
 
開發者ID:GRnice,項目名稱:PandwarfDefenderProject,代碼行數:29,代碼來源:Main2Activity.java

示例9: onReceive

@Override
public void onReceive(Context context, Intent intent) {
	String action = intent.getAction();
	if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)){
		if (isProtected()){
			BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
			if (device.getAddress().equals(mBTDevice.getAddress())){
				request(AntiTheftService.REQUEST_START_ALARM, null);
				if (!setSP.isAntiTheftOpenBTEnhancedMode()){
					request(AntiTheftService.REQUEST_STOP_PROTECT, null);
					request(AntiTheftService.REQUEST_SHOW_MSG, "已綁定藍牙設備已斷開連接,藍牙防盜服務已自動關閉.");
					onProgress(AntiTheftService.MSG_REFESH_VIEWS, null);
				}
			}
		}
	}else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)){
		int currState = intent.getExtras().getInt(BluetoothAdapter.EXTRA_STATE);
		int previusState = intent.getExtras().getInt(BluetoothAdapter.EXTRA_PREVIOUS_STATE);
		if ((previusState == BluetoothAdapter.STATE_ON) && (currState == BluetoothAdapter.STATE_TURNING_OFF)){
			//藍牙已被主動關閉
			if (setSP.isAntiTheftBTClosedAlarm()){
				request(AntiTheftService.REQUEST_START_ALARM, null);
			}
			request(AntiTheftService.REQUEST_STOP_PROTECT, null);
			request(AntiTheftService.REQUEST_SHOW_MSG,"藍牙已被關閉,藍牙防盜服務已自動關閉!");
			onProgress(AntiTheftService.MSG_REFESH_VIEWS, null);
		}
	}
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:29,代碼來源:BTProtector.java

示例10: stateToString

/** Converts BluetoothAdapter states into local string representations. */
private String stateToString(int state) {
  switch (state) {
    case BluetoothAdapter.STATE_DISCONNECTED:
      return "DISCONNECTED";
    case BluetoothAdapter.STATE_CONNECTED:
      return "CONNECTED";
    case BluetoothAdapter.STATE_CONNECTING:
      return "CONNECTING";
    case BluetoothAdapter.STATE_DISCONNECTING:
      return "DISCONNECTING";
    case BluetoothAdapter.STATE_OFF:
      return "OFF";
    case BluetoothAdapter.STATE_ON:
      return "ON";
    case BluetoothAdapter.STATE_TURNING_OFF:
      // Indicates the local Bluetooth adapter is turning off. Local clients should immediately
      // attempt graceful disconnection of any remote links.
      return "TURNING_OFF";
    case BluetoothAdapter.STATE_TURNING_ON:
      // Indicates the local Bluetooth adapter is turning on. However local clients should wait
      // for STATE_ON before attempting to use the adapter.
      return  "TURNING_ON";
    default:
      return "INVALID";
  }
}
 
開發者ID:Piasy,項目名稱:AppRTC-Android,代碼行數:27,代碼來源:AppRTCBluetoothManager.java

示例11: onReceive

@Override
public void onReceive(Context context, Intent intent) {
	Log.d(LOG_TAG, "onReceive");
	final String action = intent.getAction();

	String stringState = "";
	if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
		final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
				BluetoothAdapter.ERROR);
		switch (state) {
			case BluetoothAdapter.STATE_OFF:
				stringState = "off";
				break;
			case BluetoothAdapter.STATE_TURNING_OFF:
				stringState = "turning_off";
				break;
			case BluetoothAdapter.STATE_ON:
				stringState = "on";
				break;
			case BluetoothAdapter.STATE_TURNING_ON:
				stringState = "turning_on";
				break;
		}
	}

	WritableMap map = Arguments.createMap();
	map.putString("state", stringState);
	Log.d(LOG_TAG, "state: " + stringState);
	sendEvent("BleAdminDidUpdateState", map);
}
 
開發者ID:YbrainInc,項目名稱:react-native-ble-quick-sdk,代碼行數:30,代碼來源:BleAdmin.java

示例12: onReceive

@Override
public void onReceive(final Context context, final Intent intent) {
    final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 0);

    if (state == BluetoothAdapter.STATE_TURNING_OFF || state == BluetoothAdapter.STATE_OFF) {
        log.info("bluetooth was turned off, stopping service");

        stopSelf();
    }
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:10,代碼來源:AcceptBluetoothService.java

示例13: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equalsIgnoreCase(BluetoothAdapter.ACTION_STATE_CHANGED)) {
        switch (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) {
            case BluetoothAdapter.STATE_ON:
                BluetoothSyncService.startOrPromptBluetooth(context);
                break;
            case BluetoothAdapter.STATE_TURNING_OFF:
            case BluetoothAdapter.STATE_OFF:
                Intent stopSyncServiceIntent = new Intent(context, BluetoothSyncService.class);
                context.stopService(stopSyncServiceIntent);
                break;
        }
    }
}
 
開發者ID:aarmea,項目名稱:noise,代碼行數:15,代碼來源:BluetoothSyncServiceManager.java


注:本文中的android.bluetooth.BluetoothAdapter.STATE_TURNING_OFF屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。