Open pdrhlik opened 3 years ago
Error code 3 means the android device doesn't have a sensor available to use:
Despite of the suppress deprecation, the method doesn't appear to be deprecated: https://developer.android.com/reference/android/hardware/SensorManager#getSensorList(int)
So this suggest that your device doesn't have an Orientation sensor. The constant is deprecated however, so perhaps you can try replacing it with SensorManager.getOrientation()
instead?
Thanks a lot for the clarification @breautek. I didn't realise my phone doesn't have the sensor, which really is the case. So everything's ok then.
I would only suggest documenting ERROR_FAILED_TO_START
on the main page so it's a bit more obvious for other people. Thanks again!
We can leave this ticket as a reminder to improve documentation
I am experiencing the same issue using an "SM A125U1" phone (Android 12).
Would it be possible for the plugin to throw CompassError.COMPASS_NOT_SUPPORTED when this happens?
Hello,
I am experiencing the same issue with a Xiaomi Redmi Note 11.
When I go to the Google Maps App, the compass indication works fine and smoothly. So I don't suppose this is about the sensor … maybe a permission or something else?
In my Ionic app, when I try to watch the headings, I get this error code 3.
Kind regards, Loïc
Hello,
No news about the previous message ⬆️ ? I still have the issue (CompassError Code 3) on Xiaomi Redmi Note 10 and 11 even if the compass is well indicated in other apps.
Someone could help me with this?
Thanks, Loïc
Hello,
No news about the previous message ⬆️ ? I still have the issue (CompassError Code 3) on Xiaomi Redmi Note 10 and 11 even if the compass is well indicated in other apps.
Someone could help me with this?
Thanks, Loïc
https://github.com/apache/cordova-plugin-device-orientation/issues/63#issuecomment-818232652
Error code 3 is returned if the compass sensor could not start, which is the case if the sensor could not be found. This is likely because the sensor (TYPE_ORIENTATION) is deprecated and has been deprecated for some time now and replaced with a non-sensor getOrientation
API.
There is no open PR that makes this change, but there is https://github.com/apache/cordova-plugin-device-orientation/pull/78 which attempts to simulate orientation sensor by fusing two different sensors together. I'm not sure if I agree with this approach, but you could test it to see if it solves your problem.
Hello @breautek,
Thank you for your reply :)
I tried to replace the file compassListener.java
in /node_modules/cordova-plugin-device-orientation/src/android/CompassListener.java
.
I see a little difference because I don't get an error that don't return the event callback data BUT, now, the event is returned but with incomplete values:
{
headingAccuracy: 3
magneticHeading: undefined
timestamp: 1693572512780
trueHeading: undefined
}
Do you have an idea why?
Kind regards, Loïc
Bug Report
Problem
When subscribing to a
watchHeading
function, I get aCompassError {code: 3}
response. It works on older Android phones. I haven't tested iOS. If I browsed the code correctly. The error code is neither one ofCompassError.COMPASS_INTERNAL_ERR CompassError.COMPASS_NOT_SUPPORTED
.What is expected to happen?
It should work.
What does actually happen?
I get an undocumented
CompassError
.Information
It doesn't work on Android 10.
Command or Code
Environment, Platform, Device
I used Angular 11, Ionic framework 5 and Capacitor.
Version information
ionic info
output:Checklist