AltitudeConverter.TryAddMslAltitudeToLocation(Location) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Same as #addMslAltitudeToLocation(Context, Location)
except that this method can be
called on the main thread as data will not be loaded from raw assets.
[Android.Runtime.Register("tryAddMslAltitudeToLocation", "(Landroid/location/Location;)Z", "", ApiSince=35)]
public bool TryAddMslAltitudeToLocation (Android.Locations.Location location);
[<Android.Runtime.Register("tryAddMslAltitudeToLocation", "(Landroid/location/Location;)Z", "", ApiSince=35)>]
member this.TryAddMslAltitudeToLocation : Android.Locations.Location -> bool
Parameters
- location
- Location
Returns
- Attributes
Remarks
Same as #addMslAltitudeToLocation(Context, Location)
except that this method can be called on the main thread as data will not be loaded from raw assets. Returns true if a Mean Sea Level altitude is added to the location
; otherwise, returns false and leaves the location
unchanged.
Prior calls to #addMslAltitudeToLocation(Context, Location)
off the main thread are necessary to load data from raw assets. Example code on the main thread is as follows:
{@code
if (!mAltitudeConverter.tryAddMslAltitudeToLocation(location)) {
// Queue up only one call off the main thread.
if (mIsAltitudeConverterIdle) {
mIsAltitudeConverterIdle = false;
executeOffMainThread(() -> {
try {
// Load raw assets for next call attempt on main thread.
mAltitudeConverter.addMslAltitudeToLocation(mContext, location);
} catch (IOException e) {
Log.e(TAG, "Not loading raw assets: " + e);
}
mIsAltitudeConverterIdle = true;
});
}
}
}
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.