简体   繁体   中英

magnetic field sensor in Moto 360 not sending updates

I wonder if others have experienced this as well. when attaching to the Sensor.TYPE_MAGNETIC_FIELD sensor on a Moto 360 (Android Wear), I'm not getting any updates.

the following code all works:

SensorManager sm = (SensorManager) this.getSystemService(Context.SENSOR_SERVICE);
Sensor magnetic = sm.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
Log.i("Wear", "magnetic: " + magnetic);

with the output:

I/Wear    (17471): magnetic: {Sensor name="Compass Sensor", vendor="Motorola", version=1, type=2, maxRange=4900.0, resolution=0.15, power=0.45, minDelay=40000}

but after registering a listener to this sensor, no events are ever fired.

other sensors (like the accelerometer and the gyro) work fine.

can you try shaking the device a bit and see if the compass readings show up. Also can you try to move it to another area (with less magnetic interference) .. and maybe do some figure eights to calibrate the device.

I suspect that it's a larger problem than just the 360. I just received the LG Watch R and the compass doesn't work. There is one stock watch face that has a compass, and it always points in the same direction. I installed a geocaching extension for C|Geo that is supposed to indicate distance and bearing to the target, and it always points to 12:00.
Notes from the developer indicate that this is a known problem with the SDK, where he lists this bullet in the planned features for future development:

Fully implement support for watch compasses (currently not possible due to Android Wear SDK problems).

from: https://github.com/culmor30/cgeo-wear

So it seems that this is a known problem/limitation of the SDK.

I had the same problem. But only if the watch is paired with moto x 2013 (kitkat 4.4.4). With Asus padfone 2 (kitkat 4.4.2) and with nexus 5 (Lollipop 5.1) i don't have the problem. For exemple I've tried this app : https://play.google.com/store/apps/details?id=jack.campbell.messive.compass

With the moto 360 and nexus 5 works with moto360 and moto x 2013 doesn't works. I don't know why, but i guess with next updates of Android wear will solve.

You want to register a listener and have that listener read the values when they are returned:

sm.registerListener(this, magnetic, SensorManager.SENSOR_DELAY_NORMAL);

Then implement the listener and get the values (eg. something like this):

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 * sensors
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
@Override public void onSensorChanged(SensorEvent event) {

    if(event.sensor.getType() == magnetic.getType()) {
        float mag = event.values[0];
    }
}

@Override public void onAccuracyChanged(Sensor sensor, int accuracy) {

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM