Back to project page Attendance-AutoCounter.
The source code is released under:
GNU General Public License
If you think the Android project Attendance-AutoCounter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.etonn.attendance_autocounter.bluetooth; //from w w w. j a v a 2s .c o m import android.bluetooth.BluetoothAdapter; import android.util.Log; import java.util.ArrayList; /** * Created by Cheng on 2014/11/7. */ public class BluetoothHelper { final public BluetoothAdapter mBluetoothAdapter; public BluetoothHelper() { mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); } /** * detect Bluetooth * * @return boolean */ public boolean detectBluetooth() { // detect whether device support Bluetooth if (mBluetoothAdapter == null) { Log.i("Log", "No Bluetooth"); return false; } else { return true; } } /** * detect Bluetooth on or off * * @return */ public boolean isBluetoothOpening() { if (mBluetoothAdapter.isEnabled()) { Log.i("Log", "Bluetooth is opening"); return true; } else { Log.i("Log", "Bluetooth is closed"); return false; } } /** * open Bluetooth * * @return */ public void openBluetooth() { Log.i("Log", "Bluetooth opened"); mBluetoothAdapter.enable(); } public boolean isDiscovering() { Log.i("Log", "Bluetooth is Discovering"); return mBluetoothAdapter.isDiscovering(); } public void startDiscovery() { if (!isDiscovering()) { mBluetoothAdapter.startDiscovery(); } } }