package safeluck.drive.evaluation.fragment; import android.bluetooth.BluetoothAdapter; import android.content.Context; import safeluck.drive.evaluation.app; import safeluck.drive.evaluation.bean.AYBluetoothDevice; /** * DriveJudge * Created by lzw on 2020/11/17. 13:51:16 * 邮箱:632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ public class BluetoothManager { private static final BluetoothManager ourInstance = new BluetoothManager(); private Context mContext; public static BluetoothManager getInstance() { return ourInstance; } AYBluetoothDevice ayBluetoothDevice; private BluetoothAdapter mBluetoothAdapter; private BluetoothManager() { this.mContext = app.getAppContext(); android.bluetooth.BluetoothManager manager = (android.bluetooth.BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = manager.getAdapter(); } public boolean isBluetoothEnable(){ return mBluetoothAdapter.isEnabled(); } public void startDiscovery(){ if (mBluetoothAdapter.isDiscovering()){ mBluetoothAdapter.cancelDiscovery(); } mBluetoothAdapter.startDiscovery(); } public void cancleDiscovery(){ mBluetoothAdapter.cancelDiscovery(); } }