(Flutter) Huawei Location Kit - longitude and latitude null - huawei-mobile-services

I am trying to use Huawei Location Kit(Fused Location Service) to get longitude and latitude. But the response I get back are all null. 
Then, I call the requestLocationUpdates() method to obtain the device location and update the cache. But I got PlatformException. May I know why?
My current code to use Huawei Location Kit:
Log:

I tried your code in the project, it seems working.
Can you check whether agconnect-services.json and key file is put in correct place like this:
Project screenshot:
and the API has been enabled in AppGallery Connect:
AGConnect Screenshot:

In the new Location kit 6.0.0 version, Non-Huawei Android phones support only Fused location capability. See Docs.
In addition, only some interfaces are supported. Docs link.
The requestLocationUpdates interface you use here is not supported by Non-Huawei Android phones. You are advised to use the requestLocationUpdatesCb interface instead.
Or you could use version 5.1.0.303 of the Flutter plug-in.

Related

How to test ARKit app using ARGeoTrackingConfig in unsupported area?

I have downloaded and installed this project from Apple ARKit documentation and when opening it says GeoLocation tracking is unsupported in this area. I have gone through the details and in the documentation India is not listed in supported countries or areas.
I want to try this method to test my app, and for that need a recorded session from the Reality Composer app. I searched over the internet to download a test session video but was not able to find it. If anyone can provide a solution for this.

How to get heading value from location plugin from ios? Flutter

I'm using location plugin with Google maps for flutter. When I try to give rotation to custom marker, android works perfectly but ios always returns -1. I tried flutter_compass but i read this plugin does not work Huawei, Xiaomi. What Can I do to solve this problem?
One way (probably not ideal) is to use location on Android and flutter_compass on iOS. You can perform a simple platform to see which one you're on:
if (Platform.isAndroid) {
// use location
else if (Platform.isIOS) {
// use flutter_compass
}
If the issues of flutter_compass with certain devices ever get patched, you can simply delete the check and use flutter_compass on both platforms.

Cannot get com.huawei.hms.location.LocationServices for Huawei Map Kit in android studio

I am currently trying to migrate Google Maps to Huawei map kit in my android project.
It was easy to migrate google maps to Huawei map at first. They are provided all the methods and classes that Google Maps have but now I couldn't get LocationServises class from Huawei that I used in my google maps.
In the documentation they say that Huawei Map kit has com.huawei.hms.location package and LocationServises inside. But why I cannot get it???
The links and libs that I added to gradle below: I refer the Huawei Map Kit documentation
1. maven {url 'https://developer.huawei.com/repo/'}
2. classpath 'com.huawei.agconnect:agcp:1.2.1.301'
3. maven {url 'https://developer.huawei.com/repo/'}
4. implementation 'com.huawei.hms:maps:5.1.0.300'
You can find the location services in the following artifactory
// Huawei implementation "com.huawei.hms:location:4.0.3.301"
And retrieve the location with:
FusedLocationProviderClient
Retrieve the last location with the listener
private var fusedLocationProviderClient: FusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context)
fusedLocationProviderClient.lastLocation.addOnSuccessListener { location -> Log.d("Location", location)
}
You are advised to use Huawei Location Kit because Map Kit involves only some of location functions. :)
I am migrating the Google maps to Huawei map and in the google version
there is something like public static final Api API;
variable inside LocationServises class and I need this variable in
Huawei too. But there no variable like this :/ do you know where to
get it?
Please kindly refer to the Location Kit References.
About public enum LocationType, please refer to docs here.

How to prevent user from using fake gps in Flutter Web (PWA)

I build a Flutter Web project, but I would like to know, is there a package that can handle user to prevent from using fake gps or mock location? for Android and iOS, there is package called trust_fall and trust_location to detect mock location.. how about package for Flutter Web? is there an available package for Flutter Web to detect mock location?
trust_fall depends on detecting jailbroken or SafetyNet failure, which isn't available for a webpage while trust_location credits LocationAssistant for the algorithm it use, which rely on Location.isFromMockProvider() that also unavailable for a webpage. You can use IP geolocation, but that's fraught with false positives from VPN use, and at most only accurate up to a city level.

get location on android sdk

I am very new to android.I am using android 2.3.I want to know how to get location through gps or network provider on the android emulator.When I run my application on the emulator,it does not give me the name of the network provider but displays "network".I am creating an application which requires user's current location.
can anyone please help me to do it and even how i can test if it works on emulator.
Two parts
Emulator will not give you a location. However, you can simulate a location. If you are using Eclipse, go to DDMS perspective and in the left side, you will see Emulator Controls. Scroll down to see Location Controls. You can enter location coords here.
You need to download Google API for Android (This is different from Android API). Go to your Android SDK and AVD Manager (in Eclipse this is under Menu 'Window'). Select Available Packages --> Third party Add-Ons --> Google Inc and select the API versions you want. Run the GPS emulation using these emulator