Compass issue

You must Login before you can answer or comment on any questions.

I am running android with sdk 1.8.1 on a mac in the emulator and on my buddies device (I can't remember what device that was other then it was an HTC) I am getting the following error in ddms every time i uncomment the following code.

02-13 20:52:28.385: E/TiSensorHelper(997): (main) [800,185986] unable to unregister, sensorManager is null

Ti.API.info('running once')
Ti.Geolocation.getCurrentHeading(function(e)
        {
            if (e.error)
            {
                alert( 'error: ' + e.error);
                Ti.API.info("Code translation: " +e.code + ';' + e.error + ';' +  translateErrorCode(e.code));
                return;
            }
            var x = e.heading.x;
            var y = e.heading.y;
            var z = e.heading.z;
            var magneticHeading = e.heading.magneticHeading;
            var accuracy = e.heading.accuracy;
            var trueHeading = e.heading.trueHeading;
            var timestamp = e.heading.timestamp;
 
            Titanium.API.info('geo - current heading: ' + new Date(timestamp) + ' x ' + x + ' y ' + y + ' z ' + z);
        });
It keeps running over and over even though it is supposed to only run once. I keep getting the "current heading" but running once only shows once. The callback is still commented out later in the code.

Any ideas?

1 Answer

I've had the same problem (on IOS though), so I include a var hasGotHeading = false that i set to hasGotHeading=true once ive got the value i'm after and ignore any later events

Your Answer

Think you can help? Login to answer this question!