Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 蓝牙自动开启和关闭_Android_Android Activity - Fatal编程技术网

Android 蓝牙自动开启和关闭

Android 蓝牙自动开启和关闭,android,android-activity,Android,Android Activity,自动打开蓝牙,一段时间后它会自动关闭 在android编程中可能吗 我尝试了这个BA=BluetoothAdapter.getDefaultAdapter() 这将打开蓝牙,但它不会关闭…在应用程序的第二次运行中,它将关闭 不,您不能,使用最新的棉花糖更新,您需要权限,除非用户感到满意 BA = BluetoothAdapter.getDefaultAdapter(); if (!BA.isEnabled()) { BA.enable(); Toast.makeText(get

自动打开蓝牙,一段时间后它会自动关闭

在android编程中可能吗

我尝试了这个
BA=BluetoothAdapter.getDefaultAdapter()


这将打开蓝牙,但它不会关闭…在应用程序的第二次运行中,它将关闭

不,您不能,使用最新的棉花糖更新,您需要权限,除非用户感到满意

BA = BluetoothAdapter.getDefaultAdapter();

if (!BA.isEnabled()) {
    BA.enable();
    Toast.makeText(getApplicationContext(), "Bluetooth switched On", Toast.LENGTH_LONG).show();
} if(BA.isEnabled())  {

    BA.disable();
    Toast.makeText(getApplicationContext(), "Bluetooth switched On", Toast.LENGTH_LONG).show();
}