NordicID/nur_sample_android

How to disconnect bluetooth connection?

Opened this issue · 0 comments

yk-e commented

Hi,

I make connection with your sample bluetooth connection code:

mBLEAuto= new NurApiBLEAutoConnect(context.getApplicationContext(), mNurApi);
mBLEAuto.setAddress(strAddress);

In my react native application, I want the reader connected in a particular page. When user changes the screen I try to disconnect the reader, but I could not. It disconnects if I exit the application and delete from background working apps. Here is my disconnect method, I copied it from the sample Android application here. What do I forgot?
try {
mNurApiListener.disconnectedEvent();
mNurApi.setListener(null);
this.deviceScanner.stopScan();

        if (mBLEAuto != null) {
            mBLEAuto.onDestroy();
            mBLEAuto = null;
        }

    } catch (Exception e) {
        Log.d(LogTag, "disconnect failed " + e.getMessage());
        e.printStackTrace();
    }

Thanks in advance!