致命异常SCAN BLE设备

时间:2017-01-12 03:57:40

标签: java android bluetooth-lowenergy

我尝试扫描Ble Devices,但是对于Android 5.0+已弃用stopLeScan,为此我使用public void onScanResult但是当我执行时,log显示:

  

java.lang.RuntimeException:无法实例化活动ComponentInfo {ponny.org.telemed / ponny.org.telemed.Vistas.MainActivity}:java.lang.ClassNotFoundException:找不到类" ponny .org.telemed.Vistas.MainActivity" on path:DexPathList [[zip file" /data/app/ponny.org.telemed-1/base.apk"],nativeLibraryDirectories = [/ vendor / lib64,/ system / lib64]]                                                                        在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2465)                                                                        在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2640)                                                                        在android.app.ActivityThread.access $ 800(ActivityThread.java:182)                                                                        在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1493)                                                                        在android.os.Handler.dispatchMessage(Handler.java:111)

如果我评论startLeScan,那么应用就会运行

private void scanearDispositivo(final boolean enable) {
    if (enable) {
        // Stops scanning after a pre-defined scan period.
        mHandlerScan.postDelayed(new Runnable() {
            @Override
            public void run() {
                mScanning = false;
                controladorBLE.getAdapter().stopLeScan(mLeScanCallback);
                invalidateOptionsMenu();
            }
        }, SCAN_PERIOD);

        mScanning = true;
        controladorBLE.getAdapter().startLeScan(mLeScanCallback);
     /*   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            controladorBLE.getAdapter().getBluetoothLeScanner().startScan(new ScanCallback() {
                @Override
                public void onScanResult(int callbackType, ScanResult result) {
                    super.onScanResult(callbackType, result);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        Log.println(Log.ASSERT,"BLE",result.getDevice().getName());
                    }else
                    {Log.println(Log.ASSERT,"BLE","Nada");}
                }
            });
        }*/
    } else {
        mScanning = false;
        controladorBLE.getAdapter().stopLeScan(mLeScanCallback);

    }

0 个答案:

没有答案