赞
踩
adb shell am start -n com.android.settings/com.android.settings.Settings$\VivoTetherSettingsActivity
adb shell settings get global bluetooth_on
adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE
adb shell am start -a android.bluetooth.adapter.action.REQUEST_DISABLE
adb shell dumpsys bluetooth
adb shell service call bluetooth_manager 6
adb shell am startservice -n com.android.bluetooth/.btservice.AdapterService --es command start_discovery
adb shell am startservice -n com.android.bluetooth/.btservice.AdapterService --es command cancel_discovery
adb shell am startservice -n com.android.bluetooth/.btservice.AdapterService --es command connect --es device XX:XX:XX:XX:XX:XX
adb shell am startservice -n com.android.bluetooth/.btservice.AdapterService --es command disconnect --es device XX:XX:XX:XX:XX:XX
adb shell am start -a android.bluetooth.adapter.action.REQUEST_DISCOVERABLE --ei android.bluetooth.adapter.extra.DISCOVERABLE_DURATION 300
adb shell service call bluetooth_manager 10
adb shell dumpsys bluetooth_manager | grep 'enabled:'
adb shell service call bluetooth_manager 6 # 打开蓝牙
adb shell service call bluetooth_manager 8 # 关闭蓝牙
adb root
adb shell "svc bluetooth enable"
adb root
adb shell "svc bluetooth disable"
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.bluetoothcontrol"> <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
import android.bluetooth.BluetoothAdapter; import android.os.Bundle; import android.view.View; import android.widget.Button; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { private BluetoothAdapter bluetoothAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); Button enableButton = findViewById(R.id.enableButton); Button disableButton = findViewById(R.id.disableButton); enableButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { enableBluetooth(); } }); disableButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { disableBluetooth(); } }); } private void enableBluetooth() { if (bluetoothAdapter != null && !bluetoothAdapter.isEnabled()) { bluetoothAdapter.enable(); } } private void disableBluetooth() { if (bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { bluetoothAdapter.disable(); } } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="16dp"> <Button android:id="@+id/enableButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Enable Bluetooth" /> <Button android:id="@+id/disableButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Disable Bluetooth" /> </LinearLayout>
方法一:
adb shell am start -n com.android.settings/com.android.settings.Settings$\VivoTetherSettingsActivity
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。