Cyanogen Bluetooth scan with Android API Not Working

84 views Asked by At

I am programming an Android application within Android Studio to scan the perimeter for nearby Bluetooth devices. The application works perfectly when tested upon an Android device.

When I test the application on a phone that runs on Cyanogen OS, v13.1.4 API level 5 (Elderberry), the application does not perform the BT scan as it does on the other Android phone.

I'm using this code to commence the scan process every 6 seconds and using a broadcast receiver to filter the results.

private void start() { //Handler commencing BT scan for 6s period

    BTAdapter.startDiscovery();

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Log.d("BT Search", "Scanning");
            if (BTAdapter.isDiscovering() && !status)
                BTAdapter.cancelDiscovery();
            if (status) start();
        } }, 6000);
}

I have both of the permissions specified below within my Manifest

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

Has anyone had this problem before and solved the issue?

Best wishes,

Jordan

0

There are 0 answers