Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] Fused Location Provider Plugin

Discussion in 'Assets and Asset Store' started by Lucasito, Feb 26, 2021.

  1. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    77
    Fused Location Provider Plugin.

    This asset only for Android.
    Plugin implements Fused Location Provider API. Documentation of API: https://developers.google.com/location-context/fused-location-provider
    Worked on Android 4-11.
    If the application does not have permissions, then the plugin requests it.
    If it does not work, write me, fix it. Asset has a demo scene.
    DEMO Apk for check on device: http://info.littlestories.ru/FusedLocation.apk

    =====
    Test guide

    1. Create a new empty project.
    2. Import the package (Assets/Import Package/Custom Package).
    3. Open and add in Build Settings demo scene Assets/FusedLocationProvider/Demo/Scenes/Demo.unity.
    4. Build project to android device.
    5. Start project.

    =====
    Using the plugin

    FusedLocationAPI.StartService(int interval, int fastestInterval, string locationPermissionDenied, string permissionRequiredToast, string permissionRationaleLocation)
    interval, fastestInterval - intervals for update info in ms. Documentation: https://developer.android.com/training/location/change-location-settings#location-request
    locationPermissionDenied, permissionRequiredToast, permissionRationaleLocation - texts for popup messages

    FusedLocationAPI.GetLocation(Action<FusedLocationResult> callback)
    Return on callback
    Code (CSharp):
    1. public struct FusedLocationResult {
    2.     public double Latitude;
    3.     public double Longitude;
    4.     public bool IsError;
    5. }
    if IsError is true, then something went wrong

    FusedLocationAPI.SetPriority(FusedLocationPriority priority)
    This method sets the priority of the request, which gives the Google Play services location services a strong hint about which location sources to use. The following values are supported:
    • PRIORITY_BALANCED_POWER_ACCURACY - Use this setting to request location precision to within a city block, which is an accuracy of approximately 100 meters. This is considered a coarse level of accuracy, and is likely to consume less power. With this setting, the location services are likely to use WiFi and cell tower positioning. Note, however, that the choice of location provider depends on many other factors, such as which sources are available.
    • PRIORITY_HIGH_ACCURACY - Use this setting to request the most precise location possible. With this setting, the location services are more likely to use GPS to determine the location.
    • PRIORITY_LOW_POWER - Use this setting to request city-level precision, which is an accuracy of approximately 10 kilometers. This is considered a coarse level of accuracy, and is likely to consume less power.
    • PRIORITY_NO_POWER - Use this setting if you need negligible impact on power consumption, but want to receive location updates when available. With this setting, your app does not trigger any location updates, but receives locations triggered by other apps.

    FusedLocationAPI.StopService()
    Stops the service.
     

    Attached Files:

unityunity