Android Open Source - Attendance-AutoCounter Bluetooth Helper






From Project

Back to project page Attendance-AutoCounter.

License

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.

Java Source Code

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();
        }
    }

}




Java Source Code List

com.etonn.attendance_autocounter.ApplicationTest.java
com.etonn.attendance_autocounter.ClassActivity.java
com.etonn.attendance_autocounter.CourseModifyDialog.java
com.etonn.attendance_autocounter.EmailAbsenteeActivity.java
com.etonn.attendance_autocounter.MainActivity.java
com.etonn.attendance_autocounter.ReportActivity.java
com.etonn.attendance_autocounter.ScanningActivity.java
com.etonn.attendance_autocounter.bluetooth.BluetoothHelper.java
com.etonn.attendance_autocounter.db.Attendance.java
com.etonn.attendance_autocounter.db.Course.java
com.etonn.attendance_autocounter.db.DBHelper.java
com.etonn.attendance_autocounter.db.DBManager.java
com.etonn.attendance_autocounter.db.Student.java