Guides & References
Explore the guides and references for implementing Location Kit in Unity with HMS Unity Plugin.
Developing the Fused Location Service
Assigning App Permissions
1-) Declare the required permissions in the AndroidManifest.xml file. The Android OS provides two location permissions: ACCESS_COARSE_LOCATION (approximate location permission) and ACCESS_FINE_LOCATION (precise location permission).
2-) (Optional) If your app needs to continuously locate the device when it runs in the background in Android 10 or later, declare the ACCESS_BACKGROUND_LOCATION permission in the AndroidManifest.xml file.
Dynamically apply for related location permissions (according to requirements for dangerous permissions in Android 6.0 or later).
Requesting Location Updates
By using DefineLocationCallback() you can listen for onLocationResult and onLocationAvailability.
Then you can simply listen to the actions to get the locationResult and locationAvailability.
Developing Activity Identification Service
To use the activity identification service in versions earlier than Android 10, declare the following permission in the AndroidManifest.xml file:
To use the activity identification service in Android 10 and later versions, declare the following permission in the AndroidManifest.xml file:
Note: The android.permission.ACTIVITY_RECOGNITION and com.huawei.hms.permission.ACTIVITY_RECOGNITION permissions are dangerous permissions and need to be dynamically applied for.
Create a PendingIntent object
RequestActivityIdentification / ActivityConversionUpdates
How to Listen OnReceive from BroadcastReceiver
You can listen OnReceive by using the following line and adding your OnReceive Method
Developing the Geofence Service
To use the geofence service APIs of Location Kit, declare the ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions in the AndroidManifest.xml file.
In Android 10, declare the ACCESS_BACKGROUND_LOCATION permission in the AndroidManifest.xml file so that your app can obtain the device location when it runs in the background.
Note: The preceding permissions are dangerous permissions and need to be dynamically applied for.
Initialize Geofence Receiver and LocationResult
Note: By listening GeofenceReceiver's onReceive method you can get intent result from GeoFenceBroadcastReceiver which extends BroadcastReceiver.
InitGeofenceServiceClient
Send the request to add a geofence
Set your onReceive Method
Last updated