Garmin Health Android:java.lang.IllegalStateException:设备已配对

时间:2018-11-21 15:42:26

标签: android garmin

我正在为garmin android sdk构建Unity桥。我正在尝试与Garmin设备配对。在第一次试用时,它要求输入密码并成功连接。如果我重新启动该应用程序并尝试再次配对,则会抛出此异常:

11-21 19:33:07.640  9601  9601 E AndroidRuntime: FATAL EXCEPTION: main
11-21 19:33:07.640  9601  9601 E AndroidRuntime: Process: com.rikkir.moodie, PID: 9601
11-21 19:33:07.640  9601  9601 E AndroidRuntime: java.lang.Error: FATAL EXCEPTION [main]
11-21 19:33:07.640  9601  9601 E AndroidRuntime: Unity version     : 2018.2.6f1
11-21 19:33:07.640  9601  9601 E AndroidRuntime: Device model      : BLU Dash X2
11-21 19:33:07.640  9601  9601 E AndroidRuntime: Device fingerprint: BLU/Dash_X2/Dash_X2:6.0/MRA58K/1477454813:user/release-keys
11-21 19:33:07.640  9601  9601 E AndroidRuntime:
11-21 19:33:07.640  9601  9601 E AndroidRuntime: Caused by: java.lang.IllegalStateException: vívosport[A1:A1:A1:A1:A1:A1] is already paired
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at com.garmin.health.awv.a(SourceFile:113)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at com.garmin.health.DeviceManager.pair(SourceFile:61)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at com.garmin.garminhealthbridge.PairingDialogFragment.onAttach(PairingDialogFragment.java:76)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.app.Fragment.onAttach(Fragment.java:1391)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:937)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1153)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.app.BackStackRecord.run(BackStackRecord.java:800)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1562)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.app.FragmentManagerImpl$1.run(FragmentManager.java:487)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:815)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:104)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:207)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:5728)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
11-21 19:33:07.640  9601  9601 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
11-21 19:33:07.644   813  2707 W ActivityManager:   Force finishing activity com.rikkir.moodie/com.unity3d.player.UnityPlayerActivity

这是我检查是否已配对的方法:

//if already paired, call the "success" callback rightaway
if(DeviceManager.getDeviceManager().getGcmPairedDevices().contains(scannedDevice)) {
    UnityPlayer.UnitySendMessage("GarminSDK", "PairingSucceeded", deviceAddress);
    return;
}
else if(DeviceManager.getDeviceManager().getPairedDevices().contains(scannedDevice)) {
    UnityPlayer.UnitySendMessage("GarminSDK", "PairingSucceeded", deviceAddress);
    return;
}

经过这些检查之后,这就是我尝试配对的方法:

DeviceManager.getDeviceManager().pair(mDevice, new DevicePairingCallback());

它崩溃了。显然,我没有正确检查设备是否已配对。该文档很少。有帮助吗?

0 个答案:

没有答案