Dcloud开发-- 打开蓝牙
这样打开APP就会直接提示是否要打开蓝牙:
<script type="text/javascript"> mui.init(); mui.plusReady(function(){ var main = plus.android.runtimeMainActivity(); var BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter"); var BAdapter = new BluetoothAdapter.getDefaultAdapter(); if (!BAdapter.isEnabled()) { BAdapter.enable(); //启动蓝牙 }else{ BAdapter.disable(); } }); </script>