cordova-plugin-device-motion start()方法中的异常

时间:2016-06-09 10:45:15

标签: android cordova ionic-framework cordova-plugins sensor

我的Android 5.1.1手机上的cordova插件cordova-plugin-device-motion出现了问题(荣誉6)。这是我的代码:

$scope.options = {
    frequency: 100, 
    deviation : 25  
};
$scope.startWatching = function() {
    $scope.watch = $cordovaDeviceMotion.watchAcceleration($scope.options);
    $scope.watch.then(null, function(error) {
        console.log('Error');
    },function(result) {
        //success callback
    });
};

在watchAcceleration()中,调用本机start()方法。我得到了有效的结果(成功回调被调用),但是我得到了以下logcat输出:


06-09 12:32:13.634: I/SensorManagerFlow(6623): registerListenerImpl
06-09 12:32:13.634: I/SensorManagerFlow(6623): java.lang.Exception
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at android.hardware.SystemSensorManager.registerListenerImpl(SystemSensorManager.java:118)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at android.hardware.SensorManager.registerListener(SensorManager.java:775)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at android.hardware.SensorManager.registerListener(SensorManager.java:682)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at org.apache.cordova.devicemotion.AccelListener.start(AccelListener.java:157)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at org.apache.cordova.devicemotion.AccelListener.execute(AccelListener.java:107)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at org.apache.cordova.PluginManager.exec(PluginManager.java:133)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at android.os.Handler.dispatchMessage(Handler.java:102)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at android.os.Looper.loop(Looper.java:135)
06-09 12:32:13.634: I/SensorManagerFlow(6623):  at android.os.HandlerThread.run(HandlerThread.java:61)

然后我通过以下方式停止录制:

$scope.watch.clearWatch();

然后重新开始:

$scope.startWatching();

我再次在logcat输出中得到相同的错误。但现在成功回调也不再被召唤了
如果有人能帮助我为什么会发生这种情况会很好:)
该错误对我的设备非常具体。我在另一个Android 5.1.1设备,Android 6设备和Iphone上测试了它。它在这些设备上运行良好。 以下列出了我手机最重要的功能:

System
Device Model: Huawei Honor 6
Model: H60-L04
Installed RAM: 3 GB LPDDR3

CPU
SoC Model: HiSilicon Kirin 920
Core Architecture: 4x ARM Cortex-A7 @ 1305 MHz
4x ARM Cortex-A15 @ 1708 MHz
Instruction Set: 32-bit ARMv7
Supported ABIs: armeabi-v7a, armeabi
Supported 32-bit ABIs: armeabi-v7a, armeabi

Android
Android Version: 5.1.1 (Lollipop)
API Level: 22
Rooted Device: No
Kernel Architecture: armv7l
Kernel Version: 3.10.74-gc69e6c2
Google Play Services Version: 9.0.83 (238-121911109)

Sensors
LSM330 3-axis Accelerometer:
iNemo Linear Acceleration sensor:

1 个答案:

答案 0 :(得分:0)

在花了足够的时间来弄清问题后,我可以得出结论,这个问题与插件无关。

Android版本升级应该可以解决问题,因为它看起来比实际的应用程序问题更像传感器问题。