/networkkit

Support libraries for Huawei Network Kit

Primary LanguageKotlinApache License 2.0Apache-2.0

Network Kit Support Libraries

Latest Version Kotlin Minimum SDK Version Gradle Version

The Network Kit Support Libraries consist of two projects: Network Kit Gson Converter and Network Kit Logging Interceptor. The project directory is as follows:

|-- Network Kit Gson Converter |-- Network Kit Logging Interceptor

Also, you can find a demo project which uses both of them.

Network Kit Gson Converter

In Android, when developers want to send objects as JSON in the HTTP request body, they need to convert them using a converter. Developers mostly use the Gson library to convert Java/Kotlin Objects into their JSON representation. Network Kit Gson Converter Library is a ready-to-use converter library that serves as a bridge between the Gson and Network Kit. The library provides the transformation for us. For details, please refer to Network Kit Gson Converter.

Network Kit Logging Interceptor

You have probably loaded some data from a remote server if you have created an Android app. While developing your app, you frequently need to see what data you are getting from the remote server to your app. Network Kit Logging Interceptor is an interceptor that lets you log all the API requests made by your app as well as the responses returned by the server. For details, please refer to Network Kit Logging Interceptor.

Demo App

The Network Kit Demo app shows the driving routes between the departure place and destination based on their coordinates. The app uses the Network Kit use make network operations and the Huawei Map Kit Directions API to get routes.

About Huawei Network Kit

Network Kit is a basic network service suite. It incorporates Huawei's experience in far-field network communications, and utilizes scenario-based RESTful APIs as well as file upload and download APIs. Therefore, Network Kit can provide you with easy-to-use device-cloud transmission channels featuring low latency, high throughput, and high security.

For more information -> Huawei Network Kit Guide

About Huawei Map Kit Directions API

Directions API provides a set of HTTPS-based APIs used to plan routes for walking, cycling, and driving, and calculate route distances. The APIs return route data in JSON format and support planning of the routes between two points.

For more information -> Huawei Map Kit Direction API Guide

What You Will Need

Hardware Requirements

  • A computer that can run Android Studio.
  • Huawei mobile device with a USB data cable for running developed apps

Software Requirements

  • Java JDK 1.8 or later
  • Android Studio 2021.2.x
  • Android SDK package
  • Android API Level 23 or higher
  • HMS Core (APK) 5.2.0.300 or later
  • EMUI 8.0 or later

Getting Started

Network Kit Demo app uses HUAWEI services. To use them, you have to create an app first. Before getting started, please sign-up for a HUAWEI developer account.

After creating the application, you need to generate a signing certificate fingerprint. Then you have to set this fingerprint to the application you created in AppGallery Connect.

  • Go to "My Projects" in AppGallery Connect.

  • Find your project from the project list and click the app on the project card.

  • On the Project Setting page, set SHA-256 certificate fingerprint to the SHA-256 fingerprint you've generated. AGC-Fingerprint

  • Change the agconnect-services.json file with yours.

  • To use Map Kit in your app, you also need to enable the service in AppGallery Connect.

  • Then, obtain the API key from AppGallery Connect. For details, please refer to Preparations for Map Kit Service

  • You need to call the URLEncoder.encode("Your apiKey", "UTF-8") method to encode the API key using encodeURI. For example, if the original API key is ABC/DFG+, the conversion result is ABC%2FDFG%2B.

  • Replace the key with the one in your API key.

Using the Application

Upon completing the essential parts of the code, connect your mobile device to the PC and enable the USB debugging mode. In the Android Studio window, click the icon to run the project you have created in Android Studio to generate an APK. Then install the APK on the mobile device.

  1. Before you run the app, make sure that you have a working internet connection.
  2. Then, open the app upon installing it on your device.
  3. You see a Main Screen that contains input areas for coordinates. Enter your departure and desination coordinates.
  4. To get routes, click the "Get Route" button.
  5. After clicking the button, you should see the driving routes between the departure place and destination based on your coordinates.

Screenshots

Libraries

  • Huawei Network Kit
  • Gson
  • ViewBinding

Contributors

  • Abdurrahim Cillioglu

License

 Copyright 2022. Explore in HMS. All rights reserved.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.