[Huawei Developers] HMS Community:
View attachment 5639833

Introduction​

In this article, we will learn how to integrate Huawei ML kit, Map kit and Location kit in Android application KnowMyBoard. Account Kit provides seamless login functionality to the app with large user base.

Location kit SDK for Android offers location-related APIs for Android apps. These APIs mainly relate to 6 functions like fused location, activity identification, geofence, high-precision location, indoor location, and geocoding. This mode is applicable to mobile phones and Huawei tablets. We are using Location kit to get location of user.

Huawei Map SDK for Android is a set of APIs that can be called to develop maps. You can use this SDK to easily add map-related functions to your Android app, including map display, map interaction, map drawing, and map style customization.

Supported Devices

View attachment 5639767

Supported Countries/Regions

Supported Countries/Regions

Development Overview

You need to install Android Studio IDE and I assume that you have prior knowledge of Android application development.

Hardware Requirements

A computer (desktop or laptop) running Windows 10.

Android phone (with the USB cable), which is used for debugging.

Software Requirements

Java JDK 1.8 or later.

Android Studio software or Visual Studio or Code installed.

HMS Core (APK) 4.X or later

Integration steps

Step 1. Huawei developer account and complete identity verification in Huawei developer website, refer to register Huawei ID.

Step 2. Create project in AppGallery Connect

Step 3. Adding HMS Core SDK

Let's start coding

MainActivity.java

LoginViewModel.java

RequestLocationData.java

navigation_graph.xml

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navigation_graph"
app:startDestination="@id/loginFragment">
<fragment
android:id="@+id/loginFragment"
android:name="com.huawei.hms.knowmyboard.dtse.activity.fragments.LoginFragment"
android:label="LoginFragment"/>
<fragment
android:id="@+id/mainFragment"
android:name="com.huawei.hms.knowmyboard.dtse.activity.fragments.MainFragment"
android:label="MainFragment"/>
<fragment
android:id="@+id/cameraFragment"
android:name="com.huawei.hms.knowmyboard.dtse.activity.fragments.CameraFragment"
android:label="fragment_camera"
tools:layout="@layout/fragment_camera" />
</navigation>

LoginFragment.java

Result

Tricks and Tips

Makes sure that agconnect-services.json file added.

Make sure required dependencies are added

Make sure that service is enabled in AGC

Enable data binding in gradle.build file

Make sure bottom navigation id's should be same as fragment id's in navigation graph

Conclusion

In this article, we have learnt how to integrate Huawei Map kit, Location kit in Android application KnowMyBoard. You can also go through previous article part-2 here. Hoping that the Map kit capabilities are helpful to you as well, like this sample, you can make use of Map kit as per your requirement.

Thank you so much for reading. I hope this article helps you to understand the integration of Huawei Map kit and Location kit in Android application KnowMyBoard.

Reference

Map Kit – Training video

Location Kit – Training video