블루투스 스캔 호출 빈도가 짧은 시간 안에 너무 잦으면

ScanCallback() 에 어떤 onScanFailed, onScanResult, onBatchScanResults 도 호출되지 않는다.

로그 > status=6 은 

D/BluetoothAdapter: isLeEnabled(): ON
D/BluetoothLeScanner: onScannerRegistered() - status=6 scannerId=-1 mScannerId=0

 

ScanCallback.java

/**
  * Fails to start scan as application tries to scan too frequently.
  * @hide
  */
public static final int SCAN_FAILED_SCANNING_TOO_FREQUENTLY = 6;

 

 

방법 1. 스캔 호출하는 시간 간격을 늘려준다.

방법 2. address 나 uuid 를 알고 있다면 직접 접속으로 스캐닝과 병행하여 구현한다.

 

- 참조 링크

https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library/issues/18#issuecomment-402412139

- 블루투스 도움되는 링크

NordicSemiconductor / Android-BLE-Library https://github.com/NordicSemiconductor/Android-BLE-Library.git

Making Android BLE work — part 1 by Martijn van Welie https://link.medium.com/jOoagTLCY4

appcompat:1.1.0 사용중인 경우, Android OS Ver. lollipop 에서 웹뷰 오류가 발생한다

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo ...
... Binary XML file ... webview

간단한 해결 법은 두 개정도.

1st. minSdk 상향 조정 : 21 -> 23

2st. lollipop 분기 처리

 - 단, 분기 처리는 하위 버전을 분기하여 관리하는 품이 하나 더 늘어나는 단점이 있다.

implementation 'androidx.appcompat:appcompat:1.1.0'
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.util.AttributeSet;
import android.webkit.WebView;

public class LollipopFixedWebView extends WebView {

    public LollipopFixedWebView(Context context) {
        super(getFixedContext(context));
    }

    public LollipopFixedWebView(Context context, AttributeSet attrs) {
        super(getFixedContext(context), attrs);
    }

    public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(getFixedContext(context), attrs, defStyleAttr);
    }

    // To fix Android Lollipop WebView problem create a new configuration on that Android version only
    private static Context getFixedContext(Context context) {
        if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) // Android Lollipop 5.0 & 5.1
            return context.createConfigurationContext(new Configuration());
        return context;
    }
}

+ Recent posts