android MAGNETIC_FIELD

Solution :

Possibility 1 :

MAGNETIC_FIELD is very unstable regarding rotation you could not relate on just some math to convert landscape and portrait values, the main reason is the hardware use different captors for different axises then when rotate occur you use a different hardware captor the value will never be the same, on some hi end device it will be the same but not on most devices.

if you want something to rely on and compatible on many devices you need to forget calculating the MAGNETIC_FIELD with rotation, but just force the orientation with your application. Force "portrait" orientation mode

Possibility 2 :

You talked about "magnetic fingerprint" of a location. if it's only about identifying a location without GPS you have plenty of other informations to work with. first "Wifi SSIDs" then "Mobile Networks Cells" also "Connected Wifi" etc. if this interest you i could give you code for it.

Possibility 3 :

If you absolutely need to calculate MAGNETIC_FIELD for your location, and don't want to force rotation... you could catch both value landscape and portrait instead of calculating them. then when you compare just compare to both values.

Also if you are looking to locate place where you have magnet or hight magnetic location you could work with a hi tolerance percentage just to detect if a magnet is present or so,

Note :

If you stick with the math don't forget that the function will be different on almost every device... don't hesitate to give more infos about your question i'll be pleased to adapt my answer ;)

你可能感兴趣的:(IoT,and,Smart,Sensing)