In this article, we can learn how to integrate Account Kit in food applications. Account Kit guides you to login through the Huawei sign in button. Ads Kit will advertise on the application. Site Kit guides you to select the places or locations. Mobile apps make our world better and easier customer to prefer comfort and quality instead of quantity.

This article will guide you to show favourite hotels or nearby hotels.

Prerequisites

  1. Must have a Huawei Developer Account.
  2. 2. Must have a Huawei phone with HMS 4.0.0.300 or later.
  3. 3. Must have a laptop or desktop with Android Studio, Jdk 1.8, SDK platform 26 and Gradle 4.6 installed.
  4. Integration Preparations
  5. 1. First register as Huawei developer and complete identity verification in Huawei developers website, refer to register a Huawei ID.
  6. 2. Create a project in android studio, refer Creating an Android Studio Project.
  7. 3. Generate a SHA-256 certificate fingerprint.
  8. 4. To generate SHA-256 certificate fingerprint. On right-upper corner of android project click Gradle, choose Project Name > app > Tasks > android, and then click signingReport, as follows.

Note: Project Name depends on the user created name.

5. Create an App in AppGallery Connect.

6. Download the agconnect-services.json file from App information, copy and paste in android Project under app directory, as follows.

7. Enter SHA-256 certificate fingerprint and click tick icon as follows.

Note: Above steps from Step 1 to 7 is common for all Huawei Kits.

8. Click Manage APIs tab and Enable required kits (Account Kit and Site Kit).

9. Add the below maven URL in build.gradle(Project) file under the repositories of buildscript, dependencies and allprojects, refer Add Configuration.

10. Add the below plugin and dependencies in build.gradle(Module) file.

11. Now Sync the gradle.

12. Add the below permissions in AndroidManifest.xml file.

Account Kit Overview

Huawei Account Kit provides for developers with simple, secure, and quick sign-in and authorization functions. User is not required to enter accounts, passwords and waiting for authorization. User can click on Sign in with Huawei ID button to quickly and securely sign in to the app. We can implement authorization code sign in use case to login to application.

Signing with Authorization Code

In this method, Account kit allows to sign-in using an ID in authorization code mode. When you click the Huawei ID signing in button, it requires the AccountAuthParams and create a service with authParams, then add startActivityForResult() method in Huawei ID signing in button with service and requestCode.

Ads Kits Overview:

Huawei Ads provides to developers a wide-ranging capabilities to deliver good quality ads content to users. This is the best way to reach target audience easily and can measure user productivity. It is very useful when we publish a free app and want to earn some money from it.

HMS Ads Kit has 7 types of Ads kits. Now we can implement Banner Ads in this application.

Banner Ads are rectangular ad images located at the top, middle or bottom of an application’s layout. Banner ads are automatically refreshed at intervals. When a user clicks a banner ad, in most cases the user will guide to the advertiser’s page.

Standard Banner Ad Dimensions

The following table lists the standard banner ad dimensions.

In this application, we can display Banner Ads in the login page, find the below code.

//Initialize the Huawei Ads SDK

. HwAds.init(this)

. // To get Banner view from the activity_main.xml. It will display at bottom of the page.

. val bottomBannerView = findViewById<BannerView>(R.id.hw_banner_view)

. val adParam = AdParam.Builder().build()

. bottomBannerView.adId = getString(R.string.banner_ad_id)

. bottomBannerView.bannerAdSize = BannerAdSize.BANNER_SIZE_SMART

. bottomBannerView.loadAd(adParam)

// Call new BannerView to create a BannerView class. It will display at top of the page.

val topBannerView = BannerView(this) topBannerView.adId=getString(R.string.banner_ad_id)

topBannerView.bannerAdSize=BannerAdSize.BANNER_SIZE_SMART

topBannerView.loadAd(adParam)

valrootView=findViewById<RelativeLayout>(R.id.root_view)

rootView.addView(topBan)

<com.huawei.hms.ads.banner.BannerView

. android:id=”@+id/hw_banner_view”

. android:layout_width=”match_parent”

. android:layout_height=”wrap_content”

. android:layout_alignParentBottom=”true”

. android:layout_marginTop=”10dp”

. android:layout_marginBottom=”10dp”

. hwads:adId=”@string/banner_ad_id”

. hwads:bannerSize=”BANNER_SIZE_360_57" />

Result

Site Kit Overview

Site Kit provides the place related services for apps. It provides that to search places with keywords, find nearby place, place suggestion for user search, and find the place details using the unique id.

Huawei Site Kit can be used in any industry based on the requirements, such as Hotels/Restaurants, Ecommerce, Weather Apps, Tours and Travel, Hospitality, Health Care etc.

Features

Keyword Search: Converts co-ordinates into street address and vice versa.

Nearby Place Search: Searches for nearby places based on the current location of the user’s device.

Place Detail Search: Searches for details about a place as reviews, time zone etc.

Place Search Suggestion: Suggest place names and addresses.

Steps

  1. Create TextSearchRequest object, which is used as the request body search by Keyword.
  2. TextSearchRequest Parameters.
  3. a. Mandatory
  4. Query: search keyword. Which is entered by user from the application.
  5. b. Optional
  6. location: longitude and latitude to which search results need to be biased.
  7. radius: search radius, in meters. The value ranges from 1 to 50000. The default value is 50000.
  8. bounds: coordinate bounds to which search results need to be biased.
  9. poiTypes: list of POI(Point of Interest) types.
  10. countryCode: country code, which complies with the ISO 3166 — 1 alpha-2 standards. This parameter is used to restrict search results to the specified country.
  11. language: language in which search results are returned. For details about the value range, please refer to language codes in Language Mapping. If this parameter is not passed, the language of the query field (preferred) or the local language is used.
  12. politicalView: Political view parameter. The value is a two-digit country code specified in the ISO 3166 — 1- alpha-2 standard.
  13. pageSize: number of records on each page. The value ranges from 1 to 20. The default value is 20.
  14. pageIndex: number of the current page. The value ranges from 1 to 60. The default value is 1.
  15. 2. Create a SearchResultListener object to listen for the search result.
  16. 3. Now call the textSearch() to get the result.

Location Kit:

Huawei Location Kit provides a fused location function which intelligently combines GNSS Wi-Fi, and base stations to precise users’ location.

Implementation of Location Kit:

Developing the fused location service

Assigning App Permission

After applying for permissions in the AndroidManifest.xml file, apply for the permissions dynamically in the code (according to requirements for dangerous permissions in Android 6.0 or later

Create a FusedLocationProviderClient instance using the onCreate() method of the location service activity in your project, and use the instance to call location-related APIs.

3. Check Location Settings

4. Continuously obtaining the device location

a. Set parameters for continuously requesting device locations

b. Define the location update callback

c. Call requestLocationUpdates() for continuous location

Call removeLocationUpdates() to stop requesting location updates

Implementation of Map Kit

Create Map Instance

Add a fragment element into the layout file and set attributes in the file

Implement OnMapReadyCallback API in app

Load SupportMapFragment in the onCreate() method and call getMapAsync() to register the callback

Call the onMapReady callback to obtain the HuaweiMap object.

Get current locations

Declare permissions

Apply it in code(according to requirements for dangerous permissions in Android 6.0).

Call the setMyLocationEnabled(true) method of the HuaweiMap object to enable the my-location function.

Tips and Tricks

Make sure you are already registered as Huawei developer.

Enable Account kit and Site kit service in the App Gallery.

Make sure your HMS Core is latest version.

Make sure you have added the agconnect-services.json file to app folder.

Make sure you have added SHA-256 fingerprint without fail.

Make sure all the dependencies are added properly.

Banner ads be can also added programmatically.

Conclusion

In this article, we have learnt integration of Account Kit, Ads Kit and Site Kit in food applications. It will guide you to show favourite hotels or nearby hotels based on the user selection.

I hope you have read this article. If you found it is helpful, please provide likes and comments.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

How to solve problems dealing with stars and numbers in a Triangle?

Laravel FormRequest Mutators / Attribute Casting

How To Deploy MySQL and Wordpress On AWS Using EKS.

Advanced image optimisation techniques — A Workable Careers Pages use case

Structured Message Formats: Thoughts on What To Log

Firmware Quality Assurance: Production monitoring

Off-Premises (Cloud& On-Premises IT Services ,Which is Better?

AWS Knowledge Series: Simple Email Service

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nandunandini

Nandunandini

More from Medium

[Ragnarok Sarah Server] WHAT are ROK POINTS (RoKs)?

OpTy-Mization

Gameplay Journal Entry #2

Hote Payant- A One-Step Solution for all PG Problem