Android Open Source - AndroidBleLib Ble Utils






From Project

Back to project page AndroidBleLib.

License

The source code is released under:

MIT License

If you think the Android project AndroidBleLib 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 io.hearty.ble.lib.utils;
// w  ww  .  j  ava  2  s.co m
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.pm.PackageManager;

/**
 * Created by ejf3 on 4/15/14.
 */
public class BleUtils {

    public static boolean hasBle(Context context) {
        // Use this check to determine whether BLE is supported on the device. Then
        // you can selectively disable BLE-related features.
        return (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE));
    }

    public static BluetoothAdapter getAdapter(Context context) {
        // Initializes Bluetooth adapter.
        final BluetoothManager bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
        return bluetoothManager.getAdapter();
    }

    public static String printDevice(BluetoothDevice device){
        return String.format("%s; %s; %s; %s", device.getAddress(), device.getName(), device.getType(), device.getBluetoothClass());
    }

}




Java Source Code List

io.hearty.ble.lib.BleScanner.java
io.hearty.ble.lib.data.BleConnect.java
io.hearty.ble.lib.data.DeviceFound.java
io.hearty.ble.lib.data.HeartRate.java
io.hearty.ble.lib.data.StoredBluetoothDevice.java
io.hearty.ble.lib.heart.BleHeartService.java
io.hearty.ble.lib.utils.BlePrefs.java
io.hearty.ble.lib.utils.BleUtils.java
io.hearty.ble.lib.utils.SampleGattAttributes.java