简体   繁体   中英

Error while stopping Location Sensor Firemonkey XE6

I'm using a TLocationSensor to get the Latitude and Longitude values. My GPS is not enabled and I'm using the network location.

Using the event onLocationChanged I save the values and set the property Active to False, but an error occurs.

Debugging I found, inside the unit System.Android.Sensors , at the procedure TUIAndroidLocationSensor.DoStop , that the line which removes the listener does not verify if the GPSListener is nil and throws an exception that closes my app. This problem does not occur when I compile for a 32-bits Windows platform, just when compiling for Android platform.

How can I solve this problem?

Edit: This issue was solved on Firemonkey XE8.

Since fixing this bug only involves modifying code in implementation section of System.Android.Sensors you can easily fix code yourself.

Copy System.Android.Sensors.pas into your project folder and add it to the project. Then add nil check in TUIAndroidLocationSensor.DoStop method to fix the bug.

When you compile your project Delphi will use your fixed System.Android.Sensors instead of default broken one.

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