Binary Princess
Binary Princess

Reputation: 51

Huawei Location Kit Fails to Obtain My Location when I am Indoor

I am working with location kit, Huawei Location Kit works well when I am in open area, but when I go indoor, it either gets location super late, or gets the location with super low precision.

My Location Request is like below:

//create a fusedLocationProviderClient
fusedLocationProviderClient = 
LocationServices.getFusedLocationProviderClient(this);
//create a settingsClient
settingsClient = LocationServices.getSettingsClient(this);
mLocationRequest = new LocationRequest();
// set the interval for location updates, in milliseconds. 
mLocationRequest.setInterval(10000);

And My Callback is :

mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
    if (locationResult != null) {
        List<Location> locations = locationResult.getLocations();
        if (!locations.isEmpty()) {
            for (Location location : locations) {
                Log.i(TAG,"onLocationResult location[Longitude,Latitude,Accuracy]:" + location.getLongitude() + "," + location.getLatitude() + "," + location.getAccuracy());
            }
        }
    }
}

@Override
public void onLocationAvailability(LocationAvailability locationAvailability) {
    if (locationAvailability != null) {
        boolean flag = locationAvailability.isLocationAvailable();
        Log.i(TAG, "onLocationAvailability isLocationAvailable:" + flag);
    }
}

Any help appreciated.

Upvotes: 1

Views: 1015

Answers (1)

Ibrahim R Serpici
Ibrahim R Serpici

Reputation: 1076

Huawei's Location Kit obtains user's location by combining data from multiple sources.

This means that in certain scenarious, data from GPS, base stations, WiFi and Bluetooth are combined to get a more accurate location.

When indoors, data from GPS cannot be obtained and as such, the other sources are needed to determine the user's location.

If a sim card is not inserted, the network location from base stations cannot be obtained either.

So if you experience problems while testing the Location Kit indoors, please ensure that you have entered a sim card into the test device and that the network is available.

Additionally, set your location request priority to the highest level in case you have a low priority settting.

locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

Another common reason for failing to obtain the location is because the HMS Core application has not been granted the Location permission.

Go to Settings --> Apps --> Apps --> HMS Core --> Permissions --> Location and check whether the "Allow all the time" option has been selected.

You can also use the SettingsClient to check in runtime if the device that your app is running on has granted this permission to the HMS Core application.

More information can be found in the developer documentation:

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/location-develop-steps-0000001050746143#EN-US_TOPIC_0000001050746143__section149231022103316

Upvotes: 3

Related Questions