<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Basavaraj Navi</title>
    <description>The latest articles on DEV Community by Basavaraj Navi (@basavaraj_navi).</description>
    <link>https://dev.to/basavaraj_navi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F808421%2Fd6131827-795b-41ca-b453-27438b5330ab.png</url>
      <title>DEV Community: Basavaraj Navi</title>
      <link>https://dev.to/basavaraj_navi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/basavaraj_navi"/>
    <language>en</language>
    <item>
      <title>Pygmy Collection Application Part 4 (Analytics Kit Custom Events)</title>
      <dc:creator>Basavaraj Navi</dc:creator>
      <pubDate>Mon, 28 Feb 2022 14:49:10 +0000</pubDate>
      <link>https://dev.to/basavaraj_navi/pygmy-collection-application-part-4-analytics-kit-custom-events-4n9m</link>
      <guid>https://dev.to/basavaraj_navi/pygmy-collection-application-part-4-analytics-kit-custom-events-4n9m</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In my last article, I have explained how to integrate an account kit finance application. Have a look into &lt;a href="https://forums.developer.huawei.com/forumPortal/en/topic/0201684625183310089?fid=0101187876626530001"&gt;Pygmy collection application Part 1 (Account kit)&lt;/a&gt;.&lt;br&gt;
In this article, we will learn how to &lt;strong&gt;integrate Analytics kit&lt;/strong&gt; kit in Pygmy collection finance application.&lt;br&gt;
&lt;strong&gt;Adding Events with Huawei Analytics Kit&lt;/strong&gt;&lt;br&gt;
This guide walks you through the process of building application that uses Huawei Analytics Kit to trigger event and can find data on the console.&lt;br&gt;
&lt;strong&gt;What You Will Build&lt;/strong&gt;&lt;br&gt;
You will build an application that triggers events, setting user properties, logging custom event etc.&lt;br&gt;
&lt;strong&gt;What You Need&lt;/strong&gt;&lt;br&gt;
About 10 minutes&lt;br&gt;
A favorite text editor or IDE(For me Android Studio)&lt;br&gt;
JDK 1.8 or later&lt;br&gt;
Gradle 4+&lt;br&gt;
SDK platform 19&lt;br&gt;
&lt;strong&gt;What is Mobile analytics?&lt;/strong&gt;&lt;br&gt;
Mobile analytics captures data from &lt;strong&gt;mobile app&lt;/strong&gt;, &lt;strong&gt;website&lt;/strong&gt;, and &lt;strong&gt;web app&lt;/strong&gt; visitors to &lt;strong&gt;identify unique users&lt;/strong&gt;, &lt;strong&gt;track their journeys&lt;/strong&gt;, &lt;strong&gt;record their behavior&lt;/strong&gt;, and report on the app’s performance. Similar to traditional web analytics, mobile analytics are used to improve conversions, and are the key to crafting world-class mobile experiences.&lt;br&gt;
&lt;strong&gt;How to complete this guide&lt;/strong&gt;&lt;br&gt;
When a person says that I know theoretical concept, only when he/she knows the answer for all WH questions. To complete this guide, lets understand all WH questions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;   Who has to use analytics?&lt;/li&gt;
&lt;li&gt;   Which one to use?&lt;/li&gt;
&lt;li&gt;   What is Huawei Analytics kit?&lt;/li&gt;
&lt;li&gt;   When to use HMS Analytics kit?&lt;/li&gt;
&lt;li&gt;   Why to use analytics kit?&lt;/li&gt;
&lt;li&gt;   Where to use analytics Kit?
Once you get answer for all the above questions, then you will get theoretical knowledge. But to understand with result you should know answer for below question.&lt;/li&gt;
&lt;li&gt;   How to integrate Huawei analytics kit?
&lt;strong&gt;Who has to use the analytics kit?&lt;/strong&gt;
The answer is very simple, the analytics kit will be used in the mobile/web application. So off course &lt;strong&gt;software developer has to use analytics kit&lt;/strong&gt;.
&lt;strong&gt;Which one to use?&lt;/strong&gt;
Since there are many analytics vendors in the market. But for mobile application I recommend Huawei analytics kit. Now definitely you will have question why? To answer this I’ll give some reasons.
Very easy to integrate.
Documentation is too good.
Community is too good. Response from community is so fast.
Moreover, it is very similar to other vendors, so no need to learn new things.
You can see events in real time.
&lt;strong&gt;What is Huawei Analytics kit?&lt;/strong&gt;
Flutter Analytics plugin enables the communication between HMS Core analytics SDK and Flutter platform. This plugin exposed all the functionality which is provided by HMS core analytics SDK.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Huawei Analytics kit offers you a range of analytics models that helps you to analyse the users’ behaviour with predefined and custom events, you can gain a deeper insight into your users, products and content. It helps you to gain insight into that how users behave on different platforms based on the user behaviour events and user attributes reported through apps.&lt;/p&gt;

&lt;p&gt;Huawei Analytics kit, our one-stop analytics platform provides developers with intelligent, convenient and powerful analytics capabilities, using this we can optimize apps performance and identify marketing channels.&lt;/p&gt;

&lt;p&gt;Collect and report custom events.&lt;br&gt;
Set a maximum of 25 user attributes.&lt;br&gt;
Automate event collection and session calculation.&lt;br&gt;
Preset event IDs and parameters.&lt;br&gt;
&lt;strong&gt;When to use HMS Analytics kit?&lt;/strong&gt;&lt;br&gt;
Mobile app analytics are a developer’s best friend. It helps you gain understanding about that how users’ behaviour and app can be optimized to reach your goals. Without mobile app analytics, you would be trying out different things blindly without any data to back up your experiments.&lt;br&gt;
That’s why it’s extremely important for developers to understand their mobile app analytics to track their progress while working towards achieving their goals.&lt;br&gt;
&lt;strong&gt;Why to use analytics kit?&lt;/strong&gt;&lt;br&gt;
Mobile app analytics are essential to development process for many reasons. They give you insights into that how users are using your app, which parts of the app they interact with, and what actions they take within the app. You can use these insights to come up with an action plan to improve your product in future, like adding new features that the users seem to need, or improve existing ones in a way that would make the users lives easier, or removing features that the users don’t seem to use.&lt;br&gt;
You’ll also gain insights into whether you’re achieving your goals for your mobile app, whether its revenue, awareness, or other KPIs, and then take the data you have to adjust your strategy and optimize your app to reach your further goals.&lt;br&gt;
When it comes to why? Always everyone thinks about benefits.&lt;br&gt;
&lt;strong&gt;Benefits of Analytics&lt;/strong&gt;&lt;br&gt;
App analytics helps you to drive ROI over every aspect of performance.&lt;br&gt;
App analytics helps you to gather accurate data to better serve for customers.&lt;br&gt;
App analytics allows you to drive personalized and customer-focused marketing.&lt;br&gt;
App analytics allowss you to track individual and group achievements of marketing goals from campaigns.&lt;br&gt;
App analytics offers data-driven insights into issues concerning churn and retention.&lt;br&gt;
&lt;strong&gt;Where to use analytics Kit?&lt;/strong&gt;&lt;br&gt;
This is very important question, because you already know why to use the analytics kit. So wherever you want understand about user behaviour, which part of the application users are using regularly, which functionality of the application users are using more. In the scenario you can use analytics kit in either mobile/web application you can use the analytics kit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now start with practical&lt;/strong&gt;&lt;br&gt;
Till now you understood theoretical concept of the analytics kit. Now let’s start with the practical example, to understand about practical we should get answer for the below question.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to integrate Huawei analytics kit in Android finance application?&lt;/strong&gt;&lt;br&gt;
To achieve this you need to follow couple of steps as follows.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;   Configure application on the AGC.&lt;/li&gt;
&lt;li&gt;   Client application development process.
&lt;strong&gt;Configure application on the AGC&lt;/strong&gt;
Follow the steps.
&lt;strong&gt;Step 1:&lt;/strong&gt; We need to &lt;a href="https://developer.huawei.com/consumer/en/doc/10104"&gt;register as a developer&lt;/a&gt; account in AppGallery Connect. If you are already developer ignore this step.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Create an app by referring to &lt;a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-get-started#createproject"&gt;Creating a Project&lt;/a&gt; and &lt;a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-get-started#createapp"&gt;Creating an App in the Project&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Set the data storage location based on current location.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Enabling Analytics Kit. &lt;strong&gt;Project setting&lt;/strong&gt; &amp;gt; &lt;strong&gt;Manage API&lt;/strong&gt; &amp;gt; &lt;strong&gt;Enable analytics kit toggle button&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Generating a Signing Certificate Fingerprint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Configuring the Signing Certificate Fingerprint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7:&lt;/strong&gt; Download your &lt;strong&gt;agconnect-services.json&lt;/strong&gt; file, paste it into the app root directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client application development process&lt;/strong&gt;&lt;br&gt;
Follow the steps.&lt;br&gt;
&lt;strong&gt;Step 1:&lt;/strong&gt; Create Android application in the Android studio (Any IDE which is your favorite)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Add the App level gradle dependencies. Choose inside project Android &amp;gt; app &amp;gt; &lt;strong&gt;build.gradle&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to integrate Ads Kit&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Configure the application on the AGC.&lt;/li&gt;
&lt;li&gt;Client application development process.&lt;/li&gt;
&lt;li&gt;Testing a Splash Ad.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Client application development process&lt;/strong&gt;&lt;br&gt;
Follow the steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create an Android application in the Android studio (Any IDE which is your favorite).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Add the App level Gradle dependencies. Choose inside project Android &amp;gt; app &amp;gt; &lt;strong&gt;build.gradle&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
dependencies {
   implementation 'com.huawei.hms:hianalytics:5.1.0.300'
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Root level gradle dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;maven { url 'https://developer.huawei.com/repo/' }
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; To allow HTTP and HTTPS network requests on devices with &lt;strong&gt;targetSdkVersion 28&lt;/strong&gt; or later, configure the following information in the &lt;strong&gt;AndroidManifest.xml&lt;/strong&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;application
...
android:usesCleartextTraffic="true"
&amp;gt;
...
&amp;lt;/application&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Initialize Ads kit activity or application class.&lt;br&gt;
&lt;strong&gt;Step 5:&lt;/strong&gt; Build Application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HuaweiUserProperty.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class HuaweiUserProperty {
    public enum KeyName {
        USER_CUSTOMER_ID("user_session_id"),
        USER_PHONE_NUMBER("user_phone_number");
        String textValue;

        KeyName(String textValue) {
            this.textValue = textValue;
        }

        public String textValue() {
            return textValue;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;HuaweiEvenParams.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public enum HuaweiEventParams {
    temp;
    public enum EventName {
        TAP("tap"),
        OPEN("open");
        String textValue;

        EventName(String textValue) {
            this.textValue = textValue;
        }

        public String textValue() {
            return textValue;
        }
    }

    public enum Key {
        PREVIOUS_SCREEN_NAME("previous_screen_name"),
        SCREEN_NAME("screen_name"),
        UI_ELEMENT("ui_element_name"),
        DESCRIPTION("description_key"),
        PARENT_SCREEN_NAME("parent_screen_name"),
        CUSTOMER_ID("customer_id"),
        MODEL_NUMBER("model_number");

        String textValue;

        Key() {
        }

        Key(String textValue) {
            this.textValue = textValue;
        }

        String textValue() {
            return this.textValue;
        }
    }

    public enum ScreenName {

        PLATFORM_APP_LAUNCHER("platform_app_launcher"),
        GRANT_PERMISSION_DIALOG_SCREEN("grant_permission_dialog_screen"),
        CONFIGURATION_SCREEN("configuration_screen"),
        MAIN_SPLASH("main_splash"),
        LOGIN_SCREEN("login_screen"),
        COLLECTION_SCREEN("collection_screen"),
        PHONE_NUMBER_SCREEN("phone_number_screen"),
        PHONE_CONF_POPUP("phone_number_confirmation_popup"),
        OTP_SCREEN("otp_screen"),
        PROFILE_POPUP("profile_popup"),
        SOCIAL_MEDIA_LOGIN("social_media_login_screen"),
        MAIN_HOME_DASHBOARD("main_home_dashboard"),
        MAIN_HOME_NAVIGATION("main_home_navigation"),
        PROFILE_SCREEN("profile_screen"),
        IMAGE_SELECTION_POPUP("image_selection_popup"),
        PHONE_NUMBER_POPUP("phone_number_popup"),
        FEEDBACK_SCREEN("feedback_screen"),
        NAVIGATION_SCREEN("navigation_screen");


        String textValue;

        ScreenName(String textValue) {
            this.textValue = textValue;
        }

        String textValue() {
            return this.textValue;
        }
    }

    public enum Description {
        BACKGROUND_POPUP("background_popup"),
        OPEN_PHONE_NUMBER_SCREEN("open_phone_number_screen"),
        OPEN_TERMS_AND_CONDITION_SCREEN("open_terms_and_condition"),
        OPEN_PHONE_NUMBER_CONFIRMATION_POPUP("open_phone_number_confirmation_popup"),
        OPEN_OTP_SCREEN("open_otp_screen"),
        PHONE_NUMBER_SCREEN("phone_number_screen"),
        OPEN_PROFILE_POPUP("open_profile_popup"),
        SOCIAL_MEDIA_LOGIN_SCREEN("social_media_login_screen"),
        MAIN_HOME_DASHBOARD("main_home_dashboard"),
        OPEN_PROFILE_SCREEN("open_profile_screen"),
        OPEN_RECONNECTION_POPUP("open_reconnection_popup"),
        OPEN_MAIN_HOME_NAVIGATION("open_main_home_navigation"),
        OPEN_IMAGE_SELECTION_POPUP("open_image_selection_popup"),
        EDIT_PHONE_NUMBER_POPUP("edit_phone_number_popup"),
        OPEN_GALLERY("open_gallery"),
        OPEN_CAMERA("open_camera"),
        OPEN_CONTACT_SCREEN("open_contact_screen"),
        OPEN_SHARE_SCREEN("show_share_screen"),
        OPEN_LOGIN_SCREEN("open_login_screen"),
        OPEN_HOME_SCREEN("open_home_screen")
        ;


        String textValue;

        Description(String textValue) {
            this.textValue = textValue;
        }

        String textValue() {
            return this.textValue;
        }
    }


    public enum UiElementName {
        SWIPE_LEFT("swipe_left"),
        SWIPE_RIGHT("swipe_right"),
        SKIP_BUTTON("skip_button"),
        NEXT_BUTTON("next_button"),
        OK_BUTTON("ok_button"),
        CANCEL_BUTTON("cancel_button"),
        RESEND_OTP_BUTTON("resend_button"),
        GALLERY_BUTTON("gallery_button"),
        CATURE_FROM_CAMERA_BUTTON("cature_from_camera_button"),
        DONE_BUTTON("done_button"),
        COLLECTION_BUTTON("collection_button"),
        GALLARY_BUTTON("gallary_button");
        String textValue;

        UiElementName(String textValue) {
            this.textValue = textValue;
        }

        String textValue() {
            return this.textValue;
        }
    }


}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;HuaweiLog.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import android.os.Bundle;
import android.util.Log;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class HuaweiLog {

    private HuaweiEventParams.EventName eventName;
    private HashMap&amp;lt;String, String&amp;gt; data = new HashMap&amp;lt;&amp;gt;();
    private HashMap&amp;lt;String, ArrayList&amp;gt; testdata = new HashMap&amp;lt;&amp;gt;();

    public HuaweiLog() {
    }

    public HuaweiEventParams.EventName getEventName() {
        return eventName;
    }

    public HuaweiLog setEventName(HuaweiEventParams.EventName eventName) {
        this.eventName = eventName;

        return this;
    }

    public HuaweiLog setPreviousScreenName(HuaweiEventParams.ScreenName previousScreenName) {
        data.put(HuaweiEventParams.Key.PREVIOUS_SCREEN_NAME.textValue(), previousScreenName.textValue());
        return this;
    }

    public HuaweiLog setDescription(HuaweiEventParams.Description description) {
        data.put(HuaweiEventParams.Key.DESCRIPTION.textValue(), description.textValue());
        return this;
    }

    public HuaweiLog setDescription(String description) {
        data.put(HuaweiEventParams.Key.DESCRIPTION.textValue(), description);
        return this;
    }

    public HuaweiLog setCustomerId(String cId) {
        data.put(HuaweiEventParams.Key.CUSTOMER_ID.textValue(), cId);
        return this;
    }

    public HuaweiLog setCustomerMobileNumber(String mobileNumber) {
        data.put(HuaweiEventParams.Key.CUSTOMER_ID.textValue(), mobileNumber);
        return this;
    }

    public HuaweiLog setParentScreenName(HuaweiEventParams.ScreenName parentScreenName) {
        data.put(HuaweiEventParams.Key.PARENT_SCREEN_NAME.textValue(), parentScreenName.textValue());
        return this;
    }

    public HuaweiLog setScreenName(HuaweiEventParams.ScreenName screenName) {
        data.put(HuaweiEventParams.Key.SCREEN_NAME.textValue(), screenName.textValue());
        return this;
    }

    public HuaweiLog setScreenName(String screenName) {
        data.put(HuaweiEventParams.Key.SCREEN_NAME.textValue(), screenName);
        return this;
    }


    public HuaweiLog setUiElementName(String uiElementName) {
        data.put(HuaweiEventParams.Key.UI_ELEMENT.textValue(), uiElementName);
        return this;
    }

    public HuaweiLog setUiElementName(HuaweiEventParams.UiElementName uiElementName) {
        data.put(HuaweiEventParams.Key.UI_ELEMENT.textValue(), uiElementName.textValue());
        return this;
    }

    public HuaweiLog setKeyAndValue(String key, String value) {
        data.put(key, value);
        return this;
    }

    public Bundle toBundle() {
        Bundle bundle = new Bundle();
        try {
            if (data != null &amp;amp;&amp;amp; data.size() &amp;gt; 0) {
                for (Map.Entry&amp;lt;String, String&amp;gt; entry : data.entrySet()) {
                    bundle.putString(entry.getKey(), entry.getValue());
                    Log.d("Huawei",entry.getKey()+" "+ entry.getValue());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bundle;
    }

    public HuaweiLog setTestDescription(ArrayList list) {
        testdata.put(HuaweiEventParams.Key.DESCRIPTION.textValue(), list);
        return this;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;HuaweiAnalyticsClient.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import android.content.Context;
import android.util.Log;

import com.huawei.hms.analytics.HiAnalytics;
import com.huawei.hms.analytics.HiAnalyticsInstance;
import com.huawei.hms.analytics.type.ReportPolicy;
import com.shea.pygmycollection.utils.UserDataUtils;

import java.util.HashSet;
import java.util.Set;

public class HuaweiAnalyticsClient {

    private static final String TAG = HuaweiAnalyticsClient.class.getSimpleName();

    private static HuaweiAnalyticsClient ourInstance;
    private static HiAnalyticsInstance mHuaweiAnalyticsClient;

    private HuaweiAnalyticsClient() {
    }

    public static HuaweiAnalyticsClient getInstance() {
        if (ourInstance == null) {
            ourInstance = new HuaweiAnalyticsClient();
        }
        return ourInstance;
    }


    public void initAnalytics(Context context) {
        mHuaweiAnalyticsClient = HiAnalytics.getInstance(context);
        if (mHuaweiAnalyticsClient == null) {
            Log.e(TAG, "Analytics Client could not be initialized.");
            return;
        }
        mHuaweiAnalyticsClient.setAnalyticsEnabled(true);
        mHuaweiAnalyticsClient.setUserId("UserId");
        mHuaweiAnalyticsClient.setAutoCollectionEnabled(true);
        if (UserDataUtils.getUserData(context) != null) {
            if (UserDataUtils.getUserId(context) != 0) {
                Integer userId = UserDataUtils.getUserId(context);
                Log.d(TAG, "initAnalytics is called");
                if (userId != null &amp;amp;&amp;amp; userId != 0) {
                    setHuaweiUserId(String.valueOf(userId));
                    putHuaweiUserProperty(HuaweiUserProperty.KeyName.USER_PHONE_NUMBER, UserDataUtils.getUserPhoneNumber(context));
                } else {
                    setHuaweiUserId("UNKNOWN");
                    putHuaweiUserProperty(HuaweiUserProperty.KeyName.USER_PHONE_NUMBER, UserDataUtils.getUserPhoneNumber(context));
                }
            } else {
                setHuaweiUserId("UNKNOWN_USER");
                putHuaweiUserProperty(HuaweiUserProperty.KeyName.USER_PHONE_NUMBER, UserDataUtils.getUserPhoneNumber(context));
            }
        }

        // Used to report an event upon app switching to the background.
        ReportPolicy moveBackgroundPolicy = ReportPolicy.ON_MOVE_BACKGROUND_POLICY;
        // Used to report an event at the specified interval.
        ReportPolicy scheduledTimePolicy = ReportPolicy.ON_SCHEDULED_TIME_POLICY;
        // Set the event reporting interval to 600 seconds.
        scheduledTimePolicy.setThreshold(600);
        Set&amp;lt;ReportPolicy&amp;gt; reportPolicies = new HashSet&amp;lt;&amp;gt;();
        // Add the ON_SCHEDULED_TIME_POLICY and ON_MOVE_BACKGROUND_POLICY policies.
        reportPolicies.add(scheduledTimePolicy);
        reportPolicies.add(moveBackgroundPolicy);
        // Set the ON_MOVE_BACKGROUND_POLICY and ON_SCHEDULED_TIME_POLICY policies.
        mHuaweiAnalyticsClient.setReportPolicies(reportPolicies);
    }

    public void logEvent(HuaweiLog log) {
        if (mHuaweiAnalyticsClient == null) {
            throw new RuntimeException("HuaweiAnalyticsClient is not initialized. Please call initAnalytics().");
        }
        try {
            mHuaweiAnalyticsClient.onEvent(log.getEventName().textValue(), log.toBundle());
            Log.d("Huawei", log.getEventName().textValue());
        } catch (Exception e) {
            Log.d(TAG, "Huawei analytics failed" + e.getMessage());
        }
    }

    public void putHuaweiUserProperty(HuaweiUserProperty.KeyName propertyKey, String value) {
        if (mHuaweiAnalyticsClient == null) {
            throw new RuntimeException("HuaweiAnalyticsClient is not initialized. Please call initAnalytics().");
        }
        try {
            mHuaweiAnalyticsClient.setUserProfile(propertyKey.textValue(), value);
        } catch (Exception e) {
            Log.d(TAG, "Huawei analytics failed", e);
        }
    }

    public void setHuaweiUserId(String userId) {
        if (mHuaweiAnalyticsClient == null) {
            throw new RuntimeException("HuaweiAnalyticsClient is not initialized. Please call initAnalytics().");
        }

        if (userId == null) {
            mHuaweiAnalyticsClient.setUserId(null);
            return;
        }
        mHuaweiAnalyticsClient.setUserId(userId);
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;AnalyticsUtils.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import android.util.Log;

public class AnalyticUtils {
    private static final String TAG = AnalyticUtils.class.getSimpleName();

    public static void logHuaweiAnalyticEvent(HuaweiLog huaweiLog) {
        try {
            HuaweiAnalyticsClient.getInstance().logEvent(huaweiLog);
            Log.d(TAG, "Huawei analytics  " + huaweiLog.toString());
        } catch (Exception e) {
            Log.d(TAG, "Huawei analytics failed");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now log the events in activity/fragments/dialog&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AnalyticUtils.logHuaweiAnalyticEvent(new HuaweiLog()
            .setScreenName(HuaweiEventParams.ScreenName.MAIN_SPLASH)
          .setDescription(HuaweiEventParams.Description.OPEN_SHARE_SCREEN)
                .setEventName(HuaweiEventParams.EventName.OPEN)
                .setUiElementName(HuaweiEventParams.UiElementName.GALLARY_BUTTON)
        );


 AnalyticUtils.logHuaweiAnalyticEvent(new HuaweiLog()
                        .setScreenName(HuaweiEventParams.ScreenName.COLLECTION_SCREEN)
                        .setDescription(HuaweiEventParams.Description.OPEN_HOME_SCREEN)
                        .setEventName(HuaweiEventParams.EventName.TAP)
                        .setUiElementName(HuaweiEventParams.UiElementName.COLLECTION_BUTTON));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YLzZvAkp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/po8afupgedl0zvklndtw.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YLzZvAkp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/po8afupgedl0zvklndtw.PNG" alt="Image description" width="880" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HVy6RF4h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xt0vyxcba4x6atgmexmn.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HVy6RF4h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xt0vyxcba4x6atgmexmn.PNG" alt="Image description" width="880" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KFTh-9xx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqr45hcwfyj0d581x1vs.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KFTh-9xx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqr45hcwfyj0d581x1vs.PNG" alt="Image description" width="880" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips and Tricks
&lt;/h2&gt;

&lt;p&gt;Make sure you added &lt;strong&gt;agconnect-service.json&lt;/strong&gt; file.&lt;br&gt;
Add internet permission in &lt;strong&gt;AndroidManifest.xml&lt;/strong&gt;&lt;br&gt;
Add the below code to download the HMS core apk&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;application ...&amp;gt;
    &amp;lt;meta-data     
        android:name="com.huawei.hms.client.channel.androidMarket"  
        android:value="false" /&amp;gt;
    ...
&amp;lt;/application&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we have learnt what is analytics, why to use analytics kit, where to use, how to use, how to integrate HMS analytics kit and how to add custom events.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/introduction-0000001050745149"&gt;Huawei Analytics&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>java</category>
      <category>hms</category>
      <category>huawei</category>
    </item>
    <item>
      <title>Pygmy Collection Application Part 3 (Crash service)</title>
      <dc:creator>Basavaraj Navi</dc:creator>
      <pubDate>Mon, 21 Feb 2022 12:43:00 +0000</pubDate>
      <link>https://dev.to/basavaraj_navi/pygmy-collection-application-part-3-crash-service-19j2</link>
      <guid>https://dev.to/basavaraj_navi/pygmy-collection-application-part-3-crash-service-19j2</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In my last article, I have explained how to integrate account kit finance application. Have a look into &lt;a href="https://forums.developer.huawei.com/forumPortal/en/topic/0201684625183310089?fid=0101187876626530001"&gt;Pygmy collection application Part 1 (Account kit)&lt;/a&gt;. And Integration of Huawei Ads kit have look into &lt;a href="https://forums.developer.huawei.com/forumPortal/en/topic/0202690688578050115"&gt;Intermediate: Pygmy Collection Application Part 2 (Ads Kit)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Huawei Crash service?&lt;/strong&gt;&lt;br&gt;
In this article, we will learn how to &lt;strong&gt;integrate Crash services&lt;/strong&gt; of &lt;strong&gt;AppGallery&lt;/strong&gt; in Pygmy collection finance application.&lt;br&gt;
Huawei Crash is a realtime crash reporting tool that helps in &lt;strong&gt;tracking&lt;/strong&gt;, &lt;strong&gt;prioritizing&lt;/strong&gt;, and &lt;strong&gt;fix&lt;/strong&gt; stability issues that compromise the quality of your app. Crashlytics also helps in troubleshooting and saves the debugging.&lt;/p&gt;

&lt;p&gt;The AppGallery Connect Crash service provides a powerful lightweight solution to app crash problems. With the service, you can &lt;strong&gt;quickly detect&lt;/strong&gt;, &lt;strong&gt;locate&lt;/strong&gt; and &lt;strong&gt;resolve&lt;/strong&gt; app crashes (unexpected exits of apps), and have access to highly readable crash reports in real time, without the need to write any code.&lt;br&gt;
To ensure stable running of your app and prevent user experience deterioration caused by crashes, you are advised to monitor the running status of your app on each device, which is the key. The Crash service provides real-time reports, revealing any crash of your app on any device. In addition, the Crash service can intelligently aggregate crashes, providing context data when a crash occurs, such as environment information and stack, for you to prioritize the crash easily for rapid resolution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why do we need the crash service?&lt;/strong&gt;&lt;br&gt;
Although apps have gone through rounds the tests before release considering the large user base diverse device models and complex network environment. It’s inevitable for apps to crash occasionally. Crashes compromise user experience, users may even uninstall app due to crashes and your app is not going to get good reviews.&lt;/p&gt;

&lt;p&gt;You can’t get sufficient crash information from reviews to locate crashes, therefore you can’t resolve them shortly. This will severely harm your business. That’s why we need to use the crash services in our apps to be more efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to integrate Crash Service&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Configure the application on the AGC.&lt;/li&gt;
&lt;li&gt;Client application development process.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. Configure application on the AGC&lt;/strong&gt;&lt;br&gt;
Follow the steps&lt;br&gt;
Step 1: We need to &lt;a href="https://developer.huawei.com/consumer/en/doc/10104"&gt;register as a developer&lt;/a&gt; account in AppGallery Connect. &lt;strong&gt;If you are already a developer ignore this step.&lt;/strong&gt;&lt;br&gt;
Step 2: Create an app by referring to &lt;a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-get-started#createproject"&gt;Creating a Project&lt;/a&gt; and Creating an App in the Project&lt;br&gt;
Step 3: Set the data storage location based on the current location.&lt;br&gt;
Step 4: Generating a Signing Certificate Fingerprint.&lt;br&gt;
Step 5: Configuring the Signing Certificate Fingerprint.&lt;br&gt;
Step 6: Download your &lt;strong&gt;agconnect-services.json&lt;/strong&gt; file, paste it into the **app **root directory.&lt;br&gt;
Step 7: Enable Crash services.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5a3cWqtt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6yqqmq12uqvl87v2wh2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5a3cWqtt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6yqqmq12uqvl87v2wh2z.png" alt="Image description" width="880" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client application development process&lt;/strong&gt;&lt;br&gt;
Follow the steps.&lt;br&gt;
Step 1: Create an Android application in the &lt;strong&gt;Android studio&lt;/strong&gt; (Any IDE which is your favorite).&lt;br&gt;
Step 2: Add the App level &lt;strong&gt;Gradle dependencies&lt;/strong&gt;. Choose inside project Android &amp;gt; app &amp;gt; build.gradle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
implementation 'com.huawei.agconnect:agconnect-crash:1.6.0.300'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;// It is recommended that you integrate the APM SDK to further locate whether an app crash is caused by an app event or behavior such as ANR, launch, and network request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;implementation 'com.huawei.agconnect:agconnect-apms:x.x.x.xxx'
implementation 'com.huawei.hms:hianalytics:5.0.5.300'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Root level gradle dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;maven { url 'https://developer.huawei.com/repo/' }
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Add permission in &lt;strong&gt;AndroidManifest.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;application&amp;gt;
&amp;lt;uses-permission android:name="android.permission.INTERNET" /&amp;gt;
&amp;lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&amp;gt;
...
&amp;lt;/application&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4: Initialize Crash Service activity or application class&lt;br&gt;
Step 5: Build Application&lt;br&gt;
&lt;strong&gt;Enable Crash Service&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AGConnectCrash.getInstance().enableCrashCollection(true);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Test Crash service.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AGConnectCrash.getInstance().testIt(context);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Set User Id&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AGConnectCrash.getInstance().setUserId("12345");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Set Log without log level&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AGConnectCrash.getInstance().log("set info log.");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Set Log with Log Level&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AGConnectCrash.getInstance().log(Log.WARN, "set warn log.");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Set custom Key pair value.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AGConnectCrash.getInstance().setCustomKey("mobileNumber", "Phone number is empty");
// Add a key-value pair of the string type.
AGConnectCrash.getInstance().setCustomKey("UserName", "Basavaraj Navi");
// Add a key-value pair of the boolean type.
AGConnectCrash.getInstance().setCustomKey("isFirstTimeUser", false);
// Add a key-value pair of the double type.
AGConnectCrash.getInstance().setCustomKey("doubleKey", 1.1);
// Add a key-value pair of the float type.
AGConnectCrash.getInstance().setCustomKey("floatKey", 1.1f);
// Add a key-value pair of the integer type.
AGConnectCrash.getInstance().setCustomKey("intKey", 0);
// Add a key-value pair of the long type.
AGConnectCrash.getInstance().setCustomKey("longKey", 11L);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Record Exception&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SimpleDateFormat format = new SimpleDateFormat(PygmyConstants.DOB_FORMAT);
try {
Date date = format.parse(dob);
customerEntity.setDateOfBirth(date);
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
AGConnectCrash.getInstance().recordException(e);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j42EswtZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0rxeuwthxh7vkap06mjn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j42EswtZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0rxeuwthxh7vkap06mjn.png" alt="Image description" width="880" height="360"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3MzBuDKC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnpjn69coawaridwursj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3MzBuDKC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnpjn69coawaridwursj.png" alt="Image description" width="880" height="316"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oFlzxiCI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qqyxqbgmcj5wy112yh9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oFlzxiCI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qqyxqbgmcj5wy112yh9y.png" alt="Image description" width="880" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips and Tricks
&lt;/h2&gt;

&lt;p&gt;Make sure you added &lt;strong&gt;agconnect-service.json&lt;/strong&gt; file.&lt;br&gt;
Add internet permission in AndroidManifest.xml.&lt;br&gt;
You can also download the crash reports.&lt;br&gt;
Conclusion&lt;br&gt;
In this article, we have learnt what the Crash service is. And how to integrate the crash service. How to record log with log level and without log level. And also we have learn how to record exception.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-crash-introduction-0000001055732708"&gt;Huawei Crash Service&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>java</category>
      <category>hms</category>
      <category>huawei</category>
    </item>
    <item>
      <title>Integration of Push kit in Unity based game</title>
      <dc:creator>Basavaraj Navi</dc:creator>
      <pubDate>Wed, 16 Feb 2022 16:29:18 +0000</pubDate>
      <link>https://dev.to/basavaraj_navi/integration-of-push-kit-in-unity-based-game-2m2b</link>
      <guid>https://dev.to/basavaraj_navi/integration-of-push-kit-in-unity-based-game-2m2b</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Push notifications offers a great way to increase your application’s user engagement and boost your retention rates by sending meaningful messages or by informing users about your application. These messages can be sent at any time and even if your app is not running at that time. To achieve this you need to follow steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Huawei Push Kit&lt;/strong&gt; is a messaging service developed by Huawei for developers to send messages to apps on users’ device in real time. Push Kit supports two types of messages: &lt;strong&gt;notification messages&lt;/strong&gt; and &lt;strong&gt;data messages&lt;/strong&gt;, which we will cover both in this tutorial. You can send notifications and data messages to your users from your server using the &lt;a href="https://developer.huawei.com/consumer/en/doc/development/HMS-3-References/push-server-send" rel="noopener noreferrer"&gt;Push Kit APIs&lt;/a&gt; or directly from the &lt;a href="https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/push-console" rel="noopener noreferrer"&gt;AppGallery Push Kit Console&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Things required&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unity Engine must be installed in the system.&lt;/li&gt;
&lt;li&gt;Huawei phone or cloud debugging.&lt;/li&gt;
&lt;li&gt;Visual Studio 2019&lt;/li&gt;
&lt;li&gt;Android SDK &amp;amp; NDK&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Steps to integrate&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign In and Create or Choose a project on AppGallery Connect portal.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg09h6rp6jwyoml35a9pn.png" alt="Image description"&gt; &lt;/li&gt;
&lt;li&gt;Navigate to Project settings and download the configuration file.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrhb0jw1k8ak7i1n9zy1.png" alt="Image description"&gt; &lt;/li&gt;
&lt;li&gt;Enable Push Kit from Manage APIs section.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqia7hbfwqpopcgdgasy.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;li&gt;Click Agree the Push service Agreement.&lt;/li&gt;
&lt;li&gt;Select Data storage location.&lt;/li&gt;
&lt;li&gt;Click Enable now Push notification.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3233sg09zv8ij2af0nsa.png" alt="Image description"&gt; &lt;/li&gt;
&lt;li&gt;Send Notification from the console.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprh2t0tkjypnzum6q5wi.png" alt="Image description"&gt; &lt;/li&gt;
&lt;li&gt;Enter all the required details and click on Submit.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqqntiz1s7fra54du6gk5.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Game Development&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new game in Unity.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F253qyx9budk25b32k6p6.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;li&gt;Now add game components and let us start game development.&lt;/li&gt;
&lt;li&gt;Download HMS Unity Plugin from below site.
&lt;a href="https://github.com/EvilMindDevs/hms-unity-plugin/releases" rel="noopener noreferrer"&gt;&lt;/a&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1stc44icyxyarmn3148c.png" alt="Image description"&gt; &lt;/li&gt;
&lt;li&gt;Open Unity Engine and import the downloaded HMS Plugin.
Choose Assets &amp;gt; Import Package&amp;gt; Custom Package
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnapaw06354sz94l94xw.png" alt="Image description"&gt; &lt;/li&gt;
&lt;li&gt;Choose Huawei &amp;gt; App Gallery.&lt;/li&gt;
&lt;li&gt;Provide the AppId and other details from agconnect-service.json file and click configure Manifest.&lt;/li&gt;
&lt;li&gt;Create Huawei Push Kit based scripts.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using UnityEngine;
namespace HuaweiHms{
    public class IPushServiceListener:AndroidJavaProxy{
        public IPushServiceListener():base("com.unity.hms.push.IPushService"){}
        public virtual void onMessageReceived(RemoteMessage arg0) {   }

        public void onMessageReceived(AndroidJavaObject arg0) {
            onMessageReceived(HmsUtil.GetHmsBase&amp;lt;RemoteMessage&amp;gt;(arg0));
        }

        public virtual void onMessageSent(string arg0) {

        }

        public virtual void onNewToken(string arg0) {

        }

        public virtual void onSendError(string arg0, BaseException arg1) {

        }
        public void onSendError(string arg0, AndroidJavaObject arg1) {
            onSendError(arg0,HmsUtil.GetHmsBase&amp;lt;BaseException&amp;gt;(arg1));
        }

        public virtual void onTokenError(BaseException arg0) {

        }
        public void onTokenError(AndroidJavaObject arg0) {
            onTokenError(HmsUtil.GetHmsBase&amp;lt;BaseException&amp;gt;(arg0));
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4o6gcze3v8l572vmu6c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4o6gcze3v8l572vmu6c.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ngiqplsz1xckdqwixnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ngiqplsz1xckdqwixnr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips and Tricks
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;HMS plugin v1.2.0.&lt;/li&gt;
&lt;li&gt;Make sure that you have installed HMS Core.&lt;/li&gt;
&lt;li&gt;The Push Kit server allows a maximum of 1,000 tokens for sending messages at a time.&lt;/li&gt;
&lt;li&gt;If exceed more than 1k it need to be sent batch wise.
## Conclusion
In this article, we have learnt what is push service, how to integrate in Unity based game. And also we have learnt that how to send notification from Huawei console to device.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/service-introduction-0000001050040060" rel="noopener noreferrer"&gt;Unity Push kit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>hms</category>
      <category>huawei</category>
      <category>unity3d</category>
    </item>
    <item>
      <title>Pygmy Collection Application Part 2 (Ads Kit)</title>
      <dc:creator>Basavaraj Navi</dc:creator>
      <pubDate>Wed, 09 Feb 2022 05:43:58 +0000</pubDate>
      <link>https://dev.to/basavaraj_navi/pygmy-collection-application-part-2-ads-kit-2gbo</link>
      <guid>https://dev.to/basavaraj_navi/pygmy-collection-application-part-2-ads-kit-2gbo</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In my last article, I have explained how to integrate account kit finance application. Have a look into Pygmy collection application Part 1 (Account kit).&lt;/p&gt;

&lt;p&gt;In this article, we will learn how to integrate Splash Ads kit in Pygmy collection finance application.&lt;/p&gt;

&lt;p&gt;First we will understand why we need Ads kit.&lt;/p&gt;

&lt;p&gt;Every company makes or builds some kind of product. Building or developing is not a big deal but marketing is the big deal to earn money.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Traditional marketing&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Putting Banners in City.&lt;/li&gt;
&lt;li&gt;Advertisement in Radio or TV or newspaper.&lt;/li&gt;
&lt;li&gt;Painting on the wall.&lt;/li&gt;
&lt;li&gt;Meeting distributors with sample of product.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, now let’s understand the drawback of each traditional marketing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Putting Banners in City&lt;/strong&gt;&lt;br&gt;
You know in one city there will be many localities, sub localities streets, area, main roads, service roads etc. How many places you will put banners? If you consider one city only you need to put so many banners and when it comes to multiple cities and globe level. Imagine you need so many marking people across all the cities. And also think about cost. As an organization they need profit with less investment. But when they go with banner advertisement they have to spent lot of money for marketing only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Advertisement in Radio or TV or newspaper&lt;/strong&gt;&lt;br&gt;
Now let’s take radio or TV advertisement and newspaper. Let’s take example in one home there are 5 people. How many TV’s will be there?&lt;/p&gt;

&lt;p&gt;Max 1 or 2.&lt;/p&gt;

&lt;p&gt;What about phones?&lt;br&gt;
Its mobile world everyone will have phone. 5 member’s means 5 phones some times more than 5 because few people will have 2-3 phones.&lt;/p&gt;

&lt;p&gt;There are thousands of channels. If you want to give advertisement how many channels you will give, 1 or 2 or max 10 channels you will give advertisement. Do you think all people will watch only those channels which you have provided advertisement?&lt;/p&gt;

&lt;p&gt;Radio and newspaper also right. Nowadays who will listen radio? Now everyone is moving towards the social media. And also everybody is reading news in mobile application nobody takes newspaper because people started think about paper is waste and people are thinking about environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Painting on the wall.&lt;/strong&gt;&lt;br&gt;
How many houses you will paint? Just think about money and time. As I said earlier, think about multiple cities and multiple streets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Meeting distributors with sample of product.&lt;/strong&gt;&lt;br&gt;
Meeting distributors with sample product. Do you think this will work out? No it won’t work out because all marketing person will not have same marketing knowledge. On top of that you should have to give training about product for them. Even after training about product they will miss some main key points of product while explaining distributors. If distributors are not convinced about product which is explained by marketing person straight away they will say “no to your product”.&lt;/p&gt;

&lt;p&gt;Nowadays, traditional marketing has left its place on digital marketing. Advertisers prefer to place their ads via mobile media rather than printed publications or large billboards. In this way, they can reach their target audience more easily and they can measure their efficiency by analysing many parameters such as ad display and the number of clicks. In addition to in-app purchases, the most common method used by mobile developers to generate revenue from their application is to create advertising spaces for advertisers.&lt;/p&gt;

&lt;p&gt;In this sense, Huawei Ads meets the needs of both advertisers and mobile developers. So what is this HMS Ads Kit, let’s take a closer look.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now let us understand Huawei Ads.&lt;/strong&gt;&lt;br&gt;
Ads Kit leverages the vast user base of Huawei devices and Huawei's extensive data capabilities to provide you with the Publisher Service, helping you to monetize traffic. Meanwhile, it provides the advertising service for advertisers to deliver personalized campaigns or commercial ads to Huawei device users.&lt;/p&gt;

&lt;p&gt;The video on this page introduces traffic monetization through Ads Kit, advantages of HUAWEI Ads Publisher Service, and the process for advertisers to display ads.&lt;/p&gt;

&lt;p&gt;You can click &lt;a href="https://developer.huawei.com/consumer/en/training/detail/101582707399567035"&gt;here&lt;/a&gt; to watch the MOOC video about Ads Kit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Huawei Ads&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Banner Ads.&lt;/li&gt;
&lt;li&gt;Native Ads.&lt;/li&gt;
&lt;li&gt;Rewarded Ads.&lt;/li&gt;
&lt;li&gt;Interstitial Ads.&lt;/li&gt;
&lt;li&gt;Splash Ads.&lt;/li&gt;
&lt;li&gt;Roll Ads.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Banner Ads.&lt;/strong&gt;&lt;br&gt;
Banner ads are rectangular images that occupy a spot within an app's layout, either at the top, middle, or bottom of the device screen. Banner ads refresh automatically at regular intervals. When a user clicks a banner ad, the user is redirected to the advertiser's page.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EIzR8h6E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qs17einghshna2q162hn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EIzR8h6E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qs17einghshna2q162hn.png" alt="Image description" width="880" height="616"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Native Ads.&lt;/strong&gt;&lt;br&gt;
Native ads can be images, text, or videos, which are less disruptive and fit seamlessly into the surrounding content to match your app design. You can customize native ads as needed.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2x2qU6DM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8gfi3fh4qzjzutjk6ka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2x2qU6DM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8gfi3fh4qzjzutjk6ka.png" alt="Image description" width="880" height="616"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Rewarded Ads.&lt;/strong&gt;&lt;br&gt;
Rewarded ads are full-screen video ads that allow users to view in exchange for in-app rewards.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g8sP2D4q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/16q28doe01n2417zhwur.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g8sP2D4q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/16q28doe01n2417zhwur.png" alt="Image description" width="880" height="616"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Interstitial Ads.&lt;/strong&gt;&lt;br&gt;
Interstitial ads are full-screen ads that cover the interface of an app. Such an ad is displayed when a user starts, pauses, or exits an app, without disrupting the user's experience.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4ogt0blm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lc1fmk9zh0ct8150aeu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4ogt0blm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lc1fmk9zh0ct8150aeu.png" alt="Image description" width="751" height="518"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Splash Ads.&lt;/strong&gt;&lt;br&gt;
Splash ads are displayed immediately after an app is launched, even before the home screen of the app is displayed. You need to design a default slogan image for the app in advance, and ensure that the default slogan image is displayed before a splash ad is loaded, enhancing user experience.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jJnS5Muf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/emoygp4y37n27xaxxizb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jJnS5Muf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/emoygp4y37n27xaxxizb.png" alt="Image description" width="589" height="404"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Rolls Ads.&lt;/strong&gt;&lt;br&gt;
Roll ads are displayed as short videos or images, before, during, or after the video content is played.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yshOwp41--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7dptkgwl28u7hj81r2x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yshOwp41--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7dptkgwl28u7hj81r2x.png" alt="Image description" width="880" height="616"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;How to integrate Ads Kit&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Configure the application on the AGC.&lt;/li&gt;
&lt;li&gt;Client application development process.&lt;/li&gt;
&lt;li&gt;Testing a Splash Ad.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Configure application on the AGC&lt;/strong&gt;&lt;br&gt;
Follow the steps&lt;br&gt;
Step 1: We need to &lt;a href="https://developer.huawei.com/consumer/en/doc/start/registration-and-verification-0000001053628148"&gt;register as a developer&lt;/a&gt; account in AppGallery Connect. If you are already a developer ignore this step.&lt;br&gt;
Step 2: Create an app by referring to &lt;a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-get-started#createproject"&gt;Creating a Project&lt;/a&gt; and &lt;a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-get-started-android-0000001058210705"&gt;Creating an App in the Project&lt;/a&gt;&lt;br&gt;
Step 3: Set the data storage location based on the current location.&lt;br&gt;
Step 4: Generating a Signing Certificate Fingerprint.&lt;br&gt;
Step 5: Configuring the Signing Certificate Fingerprint.&lt;br&gt;
Step 6: Download your agconnect-services.json file, paste it into the app root directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client application development process&lt;/strong&gt;&lt;br&gt;
Follow the steps.&lt;br&gt;
Step 1: Create an Android application in the Android studio (Any IDE which is your favorite).&lt;br&gt;
Step 2: Add the App level Gradle dependencies. Choose inside project Android &amp;gt; app &amp;gt; build.gradle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies {
implementation 'com.huawei.hms:ads:3.4.47.302'
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Root level gradle dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;maven { url 'https://developer.huawei.com/repo/' }
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: To allow HTTP and HTTPS network requests on devices with targetSdkVersion 28 or later, configure the following information in the &lt;strong&gt;AndroidManifest.xml&lt;/strong&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;application
...
android:usesCleartextTraffic="true"
&amp;gt;
...
&amp;lt;/application&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4: Initialize Ads kit activity or application class.&lt;br&gt;
Step 5: Build Application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SplashScreen.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.FrameLayout;

import com.huawei.agconnect.crash.AGConnectCrash;
import com.huawei.hms.ads.AdListener;
import com.huawei.hms.ads.AdParam;
import com.huawei.hms.ads.AudioFocusType;
import com.huawei.hms.ads.BannerAdSize;
import com.huawei.hms.ads.HwAds;
import com.huawei.hms.ads.banner.BannerView;
import com.huawei.hms.ads.splash.SplashAdDisplayListener;
import com.huawei.hms.ads.splash.SplashView;
import com.shea.pygmycollection.R;
import com.shea.pygmycollection.huaweianalytics.AnalyticUtils;
import com.shea.pygmycollection.huaweianalytics.HuaweiAnalyticsClient;
import com.shea.pygmycollection.huaweianalytics.HuaweiEventParams;
import com.shea.pygmycollection.huaweianalytics.HuaweiLog;
import com.shea.pygmycollection.utils.PygmyNavigator;
import com.shea.pygmycollection.utils.UserDataUtils;

public class SplashScreen extends AppCompatActivity {

    private static final int TIME_OUT = 3000;
    // "testq6zq98hecj" is a dedicated test ad unit ID. Before releasing your app, replace the test ad unit ID with the formal one.
    private static final String AD_ID = "testd7c5cewoj6";
    private static final int AD_TIMEOUT = 10000;
    private static final int MSG_AD_TIMEOUT = 1001;
    private static final String TAG = SplashScreen.class.getSimpleName();
    SplashView splashView;
    /**
     * Pause flag.
     * On the splash ad screen:
     * Set this parameter to true when exiting the app to ensure that the app home screen is not displayed.
     * Set this parameter to false when returning to the splash ad screen from another screen to ensure that the app home screen can be displayed properly.
     */
    private boolean hasPaused = false;
    // Callback processing when an ad display timeout message is received.
    private Handler timeoutHandler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(@NonNull Message msg) {
            if (SplashScreen.this.hasWindowFocus()) {
                jump();
            }
            return false;
        }
    });

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_screen);
        // Initialize the HUAWEI Ads SDK.
        HwAds.init(this);
        splashView = findViewById(R.id.splash_ad_view);
       // AGConnectCrash.getInstance().testIt(this);
        AGConnectCrash.getInstance().enableCrashCollection(true);
        AnalyticUtils.logHuaweiAnalyticEvent(new HuaweiLog()
                .setScreenName(HuaweiEventParams.ScreenName.MAIN_SPLASH)
                .setDescription(HuaweiEventParams.Description.OPEN_SHARE_SCREEN)
                .setEventName(HuaweiEventParams.EventName.OPEN)
                .setUiElementName(HuaweiEventParams.UiElementName.GALLARY_BUTTON)
        );
        loadAd();
    }

    SplashAdDisplayListener adDisplayListener = new SplashAdDisplayListener() {
        @Override
        public void onAdShowed() {
            // Called when an ad is displayed.
            Log.d(TAG, "onAdShowed");
            AGConnectCrash.getInstance().log("onAdShowed");
        }

        @Override
        public void onAdClick() {
            // Called when an ad is clicked.
            Log.d(TAG, "onAdClick");
            AGConnectCrash.getInstance().log(Log.INFO, "OnAClick");
        }
    };

    /**
     * When the ad display is complete, the app home screen is displayed.
     */
    private void jump() {
        if (!hasPaused) {
            hasPaused = true;
            if (UserDataUtils.isUserLoggedIn(SplashScreen.this)) {
                PygmyNavigator.navigateToHomeScreen(SplashScreen.this);
            } else {
                PygmyNavigator.navigateToLoginScreen(SplashScreen.this);
            }
            finish();
        }
    }

    /**
     * Set this parameter to true when exiting the app to ensure that the app home screen is not displayed.
     */
    @Override
    protected void onStop() {
        // Remove the timeout message from the message queue.
        timeoutHandler.removeMessages(MSG_AD_TIMEOUT);
        hasPaused = true;
        super.onStop();
    }

    /**
     * Set this parameter to false when returning to the splash ad screen from another screen to ensure that the app home screen can be displayed properly.
     */
    @Override
    protected void onRestart() {
        super.onRestart();
        hasPaused = false;
        jump();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    private void loadAd() {
        int orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        AdParam adParam = new AdParam.Builder().build();
        SplashView.SplashAdLoadListener splashAdLoadListener = new SplashView.SplashAdLoadListener() {
            @Override
            public void onAdLoaded() {
                // Called when an ad is loaded successfully.
            }

            @Override
            public void onAdFailedToLoad(int errorCode) {
                // Called when an ad fails to be loaded. The app home screen is then displayed.
                jump();
            }

            @Override
            public void onAdDismissed() {
                // Called when the display of an ad is complete. The app home screen is then displayed.
                jump();
            }
        };
        // Obtain SplashView.
        splashView.setAdDisplayListener(adDisplayListener);
        // Set the default slogan.
        splashView.setSloganResId(R.drawable.ic_baseline_account_balance_wallet_24);
        // Set the audio focus type for a video splash ad.
        splashView.setAudioFocusType(AudioFocusType.GAIN_AUDIO_FOCUS_ALL);
        // Load the ad. AD_ID indicates the ad unit ID.
        splashView.load(AD_ID, orientation, adParam, splashAdLoadListener);
        // Send a delay message to ensure that the app home screen can be properly displayed after the ad display times out.
        timeoutHandler.removeMessages(MSG_AD_TIMEOUT);
        timeoutHandler.sendEmptyMessageDelayed(MSG_AD_TIMEOUT, AD_TIMEOUT);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;activity_splash_screen.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:hwads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.activities.SplashScreen"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:gravity="center"
    android:background="@color/colorAccent"&amp;gt;

    &amp;lt;RelativeLayout
        android:id="@+id/logo_area"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_alignParentBottom="true"
        android:visibility="visible"&amp;gt;

        &amp;lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="40dp"
            android:orientation="horizontal"&amp;gt;


            &amp;lt;ImageView
                android:id="@+id/iv"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_centerInParent="true"
                android:layout_gravity="center"
                android:src="@drawable/splash_image"
                android:visibility="visible" /&amp;gt;

            &amp;lt;TextView
                android:id="@+id/appName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginLeft="20dp"
                android:gravity="center"
                android:text="eCollection"
                android:textColor="@android:color/white"
                android:textSize="40sp"
                android:textStyle="bold"
                android:visibility="visible" /&amp;gt;


        &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;/RelativeLayout&amp;gt;

    &amp;lt;!-- Splash ad view. --&amp;gt;

    &amp;lt;com.huawei.hms.ads.splash.SplashView
        android:id="@+id/splash_ad_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/logo_area" /&amp;gt;

    &amp;lt;com.huawei.hms.ads.banner.BannerView
        android:id="@+id/hw_banner_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        hwads:adId="testw6vs28auh3"
        android:visibility="gone"
        hwads:bannerSize="BANNER_SIZE_360_57"/&amp;gt;

&amp;lt;/RelativeLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Testing a Splash Ads&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kfD5CVeQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/041jsstwdo3tn97r4b24.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kfD5CVeQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/041jsstwdo3tn97r4b24.PNG" alt="Image description" width="880" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--goZSRX5C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kx97m7bnzo86xhh85ym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--goZSRX5C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kx97m7bnzo86xhh85ym.png" alt="Image description" width="880" height="1906"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o5gWqzUg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fa0k9u0qxhwy0qtjrc6d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o5gWqzUg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fa0k9u0qxhwy0qtjrc6d.png" alt="Image description" width="300" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips and Tricks
&lt;/h2&gt;

&lt;p&gt;Make sure you added &lt;strong&gt;agconnect-service.json&lt;/strong&gt; file.&lt;br&gt;
If your app can run both on Huawei mobile phones and non-Huawei Android phones (&lt;strong&gt;outside the Chinese mainland&lt;/strong&gt;), integrate the HUAWEI Ads SDK (com.huawei.hms:ads) into your app.&lt;br&gt;
If your app can run only on Huawei mobile phones, integrate the HUAWEI Ads Lite SDK (&lt;strong&gt;com.huawei.hms:ads-lite&lt;/strong&gt;).&lt;br&gt;
Add internet permission in &lt;strong&gt;AndroidManifest.xml&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we have learnt what the traditional marketing. Drawbacks of traditional marketing and Types of Huawei Ads, How to integrate &lt;strong&gt;Huawei Splash Ads&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/publisher-service-splash-0000001050066919"&gt;Huawei Splash Ads&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/publisher-service-introduction-0000001070671805"&gt;Official Huawei Ads kit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>java</category>
      <category>hms</category>
      <category>huawei</category>
    </item>
    <item>
      <title>Pygmy collection application Part 1 (Account kit)</title>
      <dc:creator>Basavaraj Navi</dc:creator>
      <pubDate>Thu, 03 Feb 2022 05:23:38 +0000</pubDate>
      <link>https://dev.to/basavaraj_navi/pygmy-collection-application-part-1-account-kit-3hgl</link>
      <guid>https://dev.to/basavaraj_navi/pygmy-collection-application-part-1-account-kit-3hgl</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Great things always take time. So this blog will be a little lengthy to convey you in a better way. I'll cover the following things&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Application basic introduction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Huawei Account kit integration.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While building this application I'll write series of article. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Application basic Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the Pygmy Collection?&lt;/strong&gt;&lt;br&gt;
Let us understand the meaning.&lt;/p&gt;

&lt;p&gt;Daily Deposit Scheme is a monetary deposit scheme introduced to help daily wage earners, small traders to inculcate saving habits and also as a way of funding their bigger capital requirements. In this scheme money can be deposited into an account on a daily basis. The amount may be as small as Rupees 20/-. The unique characteristic of this scheme is that an agent from the bank collects money to be deposited, on a daily basis, from the doorsteps of the account holder. It has provided many employment opportunities as agents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features of the scheme?&lt;/strong&gt;&lt;br&gt;
Choice to opt for Scheme Period from 12, 24, 36 months.&lt;br&gt;
Amount as low as Rs.10 per day can be saved daily/weekly/monthly.&lt;br&gt;
Benefit of this scheme is for small shopkeepers, salesmen, hawkers, etc.&lt;br&gt;
No penalty even if the depositor is unable to pay a contribution regularly.&lt;br&gt;
Deposit accounts can be closed prematurely subject to certain conditions.&lt;br&gt;
Loans can be availed upto a maximum of 85% of the balance in the Pigmy account.&lt;br&gt;
Nomination facility available.&lt;br&gt;
No tax will be deducted for the interest on the deposit. (for Members Only)&lt;br&gt;
The rates of interest are fixed by the Bank from time to time.&lt;br&gt;
If the amount is withdrawn before 6 months then a premature deduction @ 5% will be made from the deposit amount.&lt;br&gt;
Account Holder can withdraw the amount after 6 months without penalty. After completion of 1 year, interest at 2% p.a., Upto 2 year interest 3% p.a., for 3 years interest 5% p.a. will be paid to the account holder.&lt;br&gt;
&lt;strong&gt;What does this application do?&lt;/strong&gt;&lt;br&gt;
This product aims to automate the Pygmy deposit scheme in credit societies for small savers. As we see a lot of fraudulent activities in payment collectives from collection agents, the idea is to design a full proof system which involves less human effort. Credit Societies can automate their collection process by introducing generic hand-held devices for our concern, android mobile, to their field Collection Agents i.e., Cash Collectors for better control, visibility and end-Customer experience. In this application the cash collector can view the customer list where he wants to go for collection with their detailed address and also the collection plan of the customer. Collection information is sent immediately to the Credit Society server and also the customer gets a confirmation message as soon as he makes payment to the cash collector with details of the total collection amount till date. Cash collector can view the complete collection sheet of each customer at the end of month so that he will cross check it with the system and the customer. This entire system will have a web-based background for maintaining depositional transactional history.&lt;/p&gt;

&lt;p&gt;It is basically a finance application where agents will go and collect X amount of money from the shops. So that X amount will be saved in the shopkeeper's savings account. Even shopkeepers can also get the loan from the finance.&lt;/p&gt;

&lt;p&gt;Nowadays India is moving towards digital but most of the Finances are still using manual processes, where they are going with pen and paper to collect the money. But in fact the shopkeepers are not getting any messages when they pay money to the finance agent, they are not able to see the balances. And in the pen and paperwork there is not much transparency. In the project we are trying to avoid all the manual work.&lt;/p&gt;

&lt;p&gt;One tree can produce approximately 10k to 20k papers. Imagine if we make the process digital we can save trees and the environment will be safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Building an application to avoid pen and paperwork.&lt;/li&gt;
&lt;li&gt;Maintain transparency in the account information.&lt;/li&gt;
&lt;li&gt;Reduces the time and avoids fraud in the account.&lt;/li&gt;
&lt;li&gt;Handling security in the application.&lt;/li&gt;
&lt;li&gt;Scan and receive the amount.&lt;/li&gt;
&lt;li&gt;Send an amount received as a confirmation message to shopkeepers.&lt;/li&gt;
&lt;li&gt;Direction to all the shops when new agents join, there will not be much issue to travel to all the shops.&lt;/li&gt;
&lt;li&gt;Report day/week/month wise.&lt;/li&gt;
&lt;li&gt;Sending an everyday report to the manager.&lt;/li&gt;
&lt;li&gt;Save paper and save the environment.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Software and Hardware Requirement
&lt;/h2&gt;

&lt;p&gt;OS: Windows/Ubuntu/Mac&lt;br&gt;
RAM: 8 GB&lt;br&gt;
Storage 40 GB&lt;br&gt;
IDE: Android Studio&lt;br&gt;
Language: Java&lt;br&gt;
Home items detailed description&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New Account opening&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where a pygmy collection agent or manager of Finance can open a customer account using some customer basic information like First name, Last name, mobile number, Shop name, Account number(Currently its manual just to support existing finance business), Opening balance, Gender, Account type, Scheme type, address and document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Collection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Agents can collect money from customers using account search or by scanning QR code. When an agent searches for an account number or scans the QR code all customer information has been shown and the agent can enter the amount and collect money.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Report&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here the agent can get the report by daily or monthly and custom report. He can get the report between dates and the report can be exported to pdf and it can be shared with the manager to make it transparent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add Member:&lt;/strong&gt; New agents can be added in this section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;KYC update&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If any customer KYC is pending, the agent can take a photo or select it from the gallery and get the type of document and document number and the agent can verify the customer KYC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Employee profile&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Agent detail will be shown in this screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate QR Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Agents can generate QR codes for each customer and take a printout and paste in the shop. Whenever an agent goes for collection he doesn't need to ask for an account number and details; he can directly scan to get the customer details. The QR code will be saved under the eCollection folder inside the external storage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mini Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this section the agent can get the mini statement for any customer. It shows the full report of that customer and he can export it as a pdf and share it with detailed transaction details with the customer to make it transparent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Huawei Account Kit integration.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HMS (Huawei mobile services)&lt;/p&gt;

&lt;p&gt;HMS core (Huawei Mobile Services) opens a wide range of services to application developers. It offers basic services such as logging in with Huawei ID, payment services and push notifications. In addition, HMS core provides various advanced features, such as, positioning, map, machine learning, and games that provide a better experience to Huawei users.&lt;/p&gt;

&lt;p&gt;HMS Account Kit provides you with simple, secure, and quick sign-in and authorization functions. Instead of entering accounts and passwords and waiting for authentication, users can just tap the Sign in with HUAWEI ID button to quickly and securely sign in to your app with their HUAWEI IDs.&lt;/p&gt;

&lt;p&gt;Using Huawei Account Kit, users can quickly and securely sign in to the application, and the first-time user needs to authorize the application and then, the user has the ability to sign in to the app with one tap using Huawei ID. Huawei facilitates app developers to use the Account Kit on multiple device types such as phones, tablets, and smart screens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AppGallery Account&lt;br&gt;
Android Studio 3.X&lt;br&gt;
SDK Platform 19 or later&lt;br&gt;
Gradle 4.6 or later&lt;br&gt;
HMS Core (APK) 4.0.0.300 or later&lt;br&gt;
Huawei Phone EMUI 3.0 or later&lt;br&gt;
Non-Huawei Phone Android 4.4 or later&lt;br&gt;
Service integration on AppGallery.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We need to register as a developer account in AppGallery Connect&lt;/li&gt;
&lt;li&gt;Create an app by referring to Creating a Project and Creating an App in the Project&lt;/li&gt;
&lt;li&gt;Set the data storage location based on the current location.&lt;/li&gt;
&lt;li&gt;Enabling Account kit Service on AppGallery.&lt;/li&gt;
&lt;li&gt;Generating a Signing Certificate Fingerprint.&lt;/li&gt;
&lt;li&gt;Configuring the Signing Certificate Fingerprint.&lt;/li&gt;
&lt;li&gt;Get your agconnect-services.json file to the app root directory.
**
Client development
**&lt;/li&gt;
&lt;li&gt;Create android project in android studio IDE.&lt;/li&gt;
&lt;li&gt;Add the maven URL inside the repositories of buildscript and
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;allprojects respectively (project level build.gradle file).
maven { url 'https://developer.huawei.com/repo/' }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Add the classpath inside the dependency section of the project level build.gradle file.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
classpath 'com.huawei.agconnect:agcp:1.5.2.300'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Add the plugin in the app-level build.gradle file.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apply plugin: 'com.huawei.agconnect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Add the below library in the app-level build.gradle file dependencies section.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;implementation 'com.huawei.hms:hwid:6.1.0.300'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Add all the below permission in the AndroidManifest.xml.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;uses-permission android:name="android.permission.INTERNET" /&amp;gt;
&amp;lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&amp;gt;
&amp;lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&amp;gt;
&amp;lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Sync the project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let us write code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 private void huaweiLogin() {
        AccountAuthParams authParams = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM).setIdToken().createParams();
        AccountAuthService service = AccountAuthManager.getService(LoginActivity.this, authParams);
        startActivityForResult(service.getSignInIntent(), 8888);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        // Process the authorization result and obtain an ID token from AuthAccount.
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 8888) {
            Task&amp;lt;AuthAccount&amp;gt; authAccountTask = AccountAuthManager.parseAuthResultFromIntent(data);
            if (authAccountTask.isSuccessful()) {
                // The sign-in is successful, and the user's ID information and ID token are obtained.
                AuthAccount authAccount = authAccountTask.getResult();
                Log.i(TAG, "idToken:" + authAccount.getIdToken());
                Toast.makeText(this, "Welcome " + authAccount.getDisplayName() + " We need more data for registration please help us with it.", Toast.LENGTH_LONG).show();
                PygmyAgentEntity agent = PygmyDatabase.getDatabase(LoginActivity.this).agentDao().findAgent(authAccount.getEmail());
                if (agent == null) {
                    PygmyNavigator.navigateToRegisterScreenWithData(this, authAccount.getDisplayName(), authAccount.getEmail());
                } else {
                    UserDataUtils.saveUserPhoneNumber(this, agent.getMobileNumber());
                    UserDataUtils.saveUserPassword(this, agent.getPassword());
                    UserDataUtils.saveUserLoggedIn(this, true);
                    UserDataUtils.saveUserData(this, new Gson().toJson(agent));
                    PygmyNavigator.navigateToWelcomeScreen(this);
                    finish();
                }
            } else {
                // The sign-in failed. No processing is required. Logs are recorded for fault locating.
                Log.e(TAG, "sign in failed : " + ((ApiException) authAccountTask.getException()).getStatusCode());
            }
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Full code&lt;/p&gt;

&lt;p&gt;LoginActivity.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.shea.pygmycollection.ui.activities;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.google.gson.Gson;
import com.huawei.agconnect.crash.AGConnectCrash;
import com.huawei.hmf.tasks.Task;
import com.huawei.hms.ads.AdListener;
import com.huawei.hms.ads.AdParam;
import com.huawei.hms.ads.BannerAdSize;
import com.huawei.hms.ads.HwAds;
import com.huawei.hms.ads.banner.BannerView;
import com.huawei.hms.common.ApiException;
import com.huawei.hms.support.account.AccountAuthManager;
import com.huawei.hms.support.account.request.AccountAuthParams;
import com.huawei.hms.support.account.request.AccountAuthParamsHelper;
import com.huawei.hms.support.account.result.AuthAccount;
import com.huawei.hms.support.account.service.AccountAuthService;
import com.huawei.hms.support.hwid.ui.HuaweiIdAuthButton;
import com.shea.pygmycollection.R;
import com.shea.pygmycollection.data.database.PygmyDatabase;
import com.shea.pygmycollection.data.database.entities.PygmyAgentEntity;
import com.shea.pygmycollection.huaweianalytics.AnalyticUtils;
import com.shea.pygmycollection.huaweianalytics.HuaweiAnalyticsClient;
import com.shea.pygmycollection.huaweianalytics.HuaweiEventParams;
import com.shea.pygmycollection.huaweianalytics.HuaweiLog;
import com.shea.pygmycollection.utils.PygmyNavigator;
import com.shea.pygmycollection.utils.UserDataUtils;

import java.util.ArrayList;
import java.util.List;

import static maes.tech.intentanim.CustomIntent.customType;


public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
    private static final int MULTIPLE_PERMISSIONS = 2000;
    private static final int PERMISSION_REQUESTS = 100;
    Button loginBtn;
    EditText mobileNumberET;
    EditText passwordET;
    TextView registerHereBtn;
    HuaweiIdAuthButton huaweiLogin;
    public static final String TAG = LoginActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        mobileNumberET = findViewById(R.id.mobileNumberET);
        passwordET = findViewById(R.id.passwordET);
        loginBtn = findViewById(R.id.loginBtn);
        registerHereBtn = findViewById(R.id.registerHereBtn);
        huaweiLogin = findViewById(R.id.huaweiLogin);
        loginBtn.setOnClickListener(this);
        registerHereBtn.setOnClickListener(this);
        huaweiLogin.setOnClickListener(this);

        // Initialize the HUAWEI Ads SDK.
        HwAds.init(this);
        // Obtain BannerView.
        BannerView bannerView = findViewById(R.id.hw_banner_view);
        // Set the ad unit ID and ad dimensions. "testw6vs28auh3" is a dedicated test ad unit ID.
        bannerView.setAdId("testw6vs28auh3");
        bannerView.setBannerAdSize(BannerAdSize.BANNER_SIZE_360_57);
        // Set the refresh interval to 30 seconds.
        bannerView.setBannerRefresh(30);
        // Create an ad request to load an ad.
        AdParam adParam = new AdParam.Builder().build();
        bannerView.loadAd(adParam);
        bannerView.setAdListener(adListener);


        if (!UserDataUtils.getUserPhoneNumber(this).isEmpty()) {
            mobileNumberET.setText(UserDataUtils.getUserPhoneNumber(this));
        }
        if (!UserDataUtils.getUserPassword(this).isEmpty()) {
            mobileNumberET.setText(UserDataUtils.getUserPassword(this));
        }

        AnalyticUtils.logHuaweiAnalyticEvent(new HuaweiLog()
                .setScreenName(HuaweiEventParams.ScreenName.LOGIN_SCREEN)
                .setDescription(HuaweiEventParams.Description.OPEN_LOGIN_SCREEN)
                .setEventName(HuaweiEventParams.EventName.OPEN)
                .setUiElementName(HuaweiEventParams.UiElementName.GALLARY_BUTTON)
        );

        //checkPermissions();

        if (!this.allPermissionsGranted()) {
            this.getRuntimePermissions();
        }
    }

    public boolean isPermissionGranted() {
        if (Build.VERSION.SDK_INT &amp;gt;= 23) {
            if (checkSelfPermission(android.Manifest.permission.CALL_PHONE)
                    == PackageManager.PERMISSION_GRANTED) {
                Log.v("TAG", "Permission is granted");
                return true;
            } else {

                Log.v("TAG", "Permission is revoked");
                ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE}, 1);
                return false;
            }
        } else { //permission is automatically granted on sdk&amp;lt;23 upon installation
            Log.v("TAG", "Permission is granted");
            return true;
        }
    }

    private String[] getRequiredPermissions() {
        try {
            PackageInfo info =
                    this.getPackageManager()
                            .getPackageInfo(this.getPackageName(), PackageManager.GET_PERMISSIONS);
            String[] ps = info.requestedPermissions;
            if (ps != null &amp;amp;&amp;amp; ps.length &amp;gt; 0) {
                return ps;
            } else {
                return new String[0];
            }
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            return new String[0];
        }
    }

    private boolean allPermissionsGranted() {
        for (String permission : this.getRequiredPermissions()) {
            if (!LoginActivity.isPermissionGranted(this, permission)) {
                return false;
            }
        }
        return true;
    }

    private void getRuntimePermissions() {
        List&amp;lt;String&amp;gt; allNeededPermissions = new ArrayList&amp;lt;&amp;gt;();
        for (String permission : this.getRequiredPermissions()) {
            if (!LoginActivity.isPermissionGranted(this, permission)) {
                allNeededPermissions.add(permission);
            }
        }

        if (!allNeededPermissions.isEmpty()) {
            ActivityCompat.requestPermissions(
                    this, allNeededPermissions.toArray(new String[0]), LoginActivity.PERMISSION_REQUESTS);
        }
    }

    private static boolean isPermissionGranted(Context context, String permission) {
        if (ContextCompat.checkSelfPermission(context, permission)
                == PackageManager.PERMISSION_GRANTED) {
            Log.i(TAG, "Permission granted: " + permission);
            return true;
        }
        Log.i(TAG, "Permission NOT granted: " + permission);
        return false;
    }

    private AdListener adListener = new AdListener() {
        @Override
        public void onAdLoaded() {
            // Called when an ad is loaded successfully.
        }

        @Override
        public void onAdFailed(int errorCode) {
            // Called when an ad fails to be loaded.
        }

        @Override
        public void onAdOpened() {
            // Called when an ad is opened.
        }

        @Override
        public void onAdClicked() {
            // Called when an ad is clicked.
        }

        @Override
        public void onAdLeave() {
            // Called when an ad leaves an app.
        }

        @Override
        public void onAdClosed() {
            // Called when an ad is closed.
        }
    };

    public void slideUp(View view) {
        startActivity(new Intent(LoginActivity.this, WelcomeActivity.class));
        customType(LoginActivity.this, "bottom-to-up");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.loginBtn:
                login();
                break;
            case R.id.registerHereBtn:
                PygmyNavigator.navigateToRegisterScreen(this);
                break;
            case R.id.huaweiLogin:
                huaweiLogin();
                break;
        }
    }

    public void login() {
        if (mobileNumberET.getText().toString().length() == 0) {
            Toast.makeText(this, "Please enter mobile number", Toast.LENGTH_SHORT).show();
            // Add a key-value pair of the string type.
            AGConnectCrash.getInstance().setCustomKey("mobileNumber", "Phone number is empty");
            return;
        }

        if (mobileNumberET.getText().toString().length() != 10) {
            Toast.makeText(this, "Please enter valid mobile number", Toast.LENGTH_SHORT).show();
            AGConnectCrash.getInstance().setCustomKey("InvalidNumber", 10);
            return;
        }

        if (passwordET.getText().toString().length() == 0) {
            Toast.makeText(this, "Please enter password", Toast.LENGTH_SHORT).show();
            return;
        }

        if (passwordET.getText().toString().length() != 6) {
            Toast.makeText(this, "Please enter valid password", Toast.LENGTH_SHORT).show();
            return;
        }

        PygmyAgentEntity agent = PygmyDatabase.getDatabase(LoginActivity.this).agentDao().findAgent(mobileNumberET.getText().toString());
        if (agent == null) {
            Toast.makeText(this, "Agent not available", Toast.LENGTH_SHORT).show();
            return;
        } else if (!agent.getPassword().equals(passwordET.getText().toString())) {
            Toast.makeText(this, "Wrong password", Toast.LENGTH_SHORT).show();
            return;
        } else {
            UserDataUtils.saveUserPhoneNumber(this, mobileNumberET.getText().toString());
            UserDataUtils.saveUserPassword(this, passwordET.getText().toString());
            UserDataUtils.saveUserLoggedIn(this, true);
            UserDataUtils.saveUserData(this, new Gson().toJson(agent));
            PygmyNavigator.navigateToWelcomeScreen(this);
            finish();
        }

       /* if (mobileNumberET.getText().toString().equalsIgnoreCase("9731276143") &amp;amp;&amp;amp; passwordET.getText().toString().equalsIgnoreCase("123456")) {
            //Toast.makeText(this, "Valid user", Toast.LENGTH_SHORT).show();
            UserDataUtils.saveUserPassword(this, mobileNumberET.getText().toString());
            UserDataUtils.saveUserPassword(this, passwordET.getText().toString());
            UserDataUtils.saveUserLoggedIn(this, true);
            PygmyNavigator.navigateToWelcomeScreen(this);
        } else {
            Toast.makeText(this, "Invalid user", Toast.LENGTH_SHORT).show();
        }*/
    }

    private void huaweiLogin() {
        AccountAuthParams authParams = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM).setIdToken().createParams();
        AccountAuthService service = AccountAuthManager.getService(LoginActivity.this, authParams);
        startActivityForResult(service.getSignInIntent(), 8888);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        // Process the authorization result and obtain an ID token from AuthAccount.
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 8888) {
            Task&amp;lt;AuthAccount&amp;gt; authAccountTask = AccountAuthManager.parseAuthResultFromIntent(data);
            if (authAccountTask.isSuccessful()) {
                // The sign-in is successful, and the user's ID information and ID token are obtained.
                AuthAccount authAccount = authAccountTask.getResult();
                Log.i(TAG, "idToken:" + authAccount.getIdToken());
                Toast.makeText(this, "Welcome " + authAccount.getDisplayName() + " We need more data for registration please help us with it.", Toast.LENGTH_LONG).show();
                PygmyAgentEntity agent = PygmyDatabase.getDatabase(LoginActivity.this).agentDao().findAgent(authAccount.getEmail());
                if (agent == null) {
                    PygmyNavigator.navigateToRegisterScreenWithData(this, authAccount.getDisplayName(), authAccount.getEmail());
                } else {
                    UserDataUtils.saveUserPhoneNumber(this, agent.getMobileNumber());
                    UserDataUtils.saveUserPassword(this, agent.getPassword());
                    UserDataUtils.saveUserLoggedIn(this, true);
                    UserDataUtils.saveUserData(this, new Gson().toJson(agent));
                    PygmyNavigator.navigateToWelcomeScreen(this);
                    finish();
                }
            } else {
                // The sign-in failed. No processing is required. Logs are recorded for fault locating.
                Log.e(TAG, "sign in failed : " + ((ApiException) authAccountTask.getException()).getStatusCode());
            }
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        switch (requestCode) {
            case MULTIPLE_PERMISSIONS: {
                if (grantResults.length &amp;gt; 0 &amp;amp;&amp;amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {  // permissions granted.
                    //getCallDetails(); // Now you call here what ever you want :)
                } else {
                    String perStr = "";
                    for (String per : permissions) {
                        perStr += "\n" + per;
                    }   // permissions list of don't granted permission
                }
                return;
            }
        }
    }


    String[] permissions = new String[]{
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.CAMERA,
            Manifest.permission.MANAGE_EXTERNAL_STORAGE,
            Manifest.permission.CALL_PHONE
    };

    private boolean checkPermissions() {
        int result;
        List&amp;lt;String&amp;gt; listPermissionsNeeded = new ArrayList&amp;lt;&amp;gt;();

        for (String p : permissions) {
            result = ContextCompat.checkSelfPermission(getApplicationContext(), p);
            if (result != PackageManager.PERMISSION_GRANTED) {
                listPermissionsNeeded.add(p);
            }
        }

        if (!listPermissionsNeeded.isEmpty()) {
            ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]), MULTIPLE_PERMISSIONS);
            return false;
        }
        return true;
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;activity_login.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;androidx.constraintlayout.widget.ConstraintLayout 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"
    xmlns:hwads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.activities.LoginActivity"&amp;gt;

    &amp;lt;TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="8dp"
        android:fontFamily="@font/montserrat_bold"
        android:text="eCollection."
        android:textColor="@color/colorText"
        android:textSize="40sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" /&amp;gt;

    &amp;lt;TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:fontFamily="@font/montserrat_light"
        android:text="Make everything digital, Save paper"
        android:textColor="@color/colorText"
        android:textSize="16sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" /&amp;gt;

    &amp;lt;ImageView
        android:id="@+id/imageView"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="8dp"
        android:visibility="visible"
        android:background="@drawable/ic_illustration_login"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView2" /&amp;gt;

    &amp;lt;EditText
        android:id="@+id/mobileNumberET"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="24dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/bg_txt_username"
        android:fontFamily="@font/montserrat_semibold"
        android:hint="Mobile Number"
        android:inputType="number"
        android:paddingLeft="60dp"
        android:textColor="@color/colorText"
        android:textSize="40px"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView" /&amp;gt;

    &amp;lt;EditText
        android:id="@+id/passwordET"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/bg_txt_password"
        android:fontFamily="@font/montserrat_semibold"
        android:hint="Password"
        android:inputType="textPassword"
        android:paddingLeft="60dp"
        android:textColor="@color/colorText"
        android:textSize="40px"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/mobileNumberET" /&amp;gt;

    &amp;lt;TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:fontFamily="@font/montserrat_light"
        android:text="Forgot your password?"
        android:textColor="@color/colorText"
        android:textSize="32px"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.883"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/passwordET" /&amp;gt;

    &amp;lt;Button
        android:id="@+id/loginBtn"
        android:layout_width="86dp"
        android:layout_height="86dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/bg_btn_login"
        android:onClick="slideUp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.951"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView3" /&amp;gt;

    &amp;lt;TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="48dp"
        android:fontFamily="@font/montserrat_semibold"
        android:onClick="slideUp"
        android:text="Sign in"
        android:textColor="@color/colorText"
        android:textSize="48px"
        app:layout_constraintEnd_toStartOf="@+id/loginBtn"
        app:layout_constraintTop_toBottomOf="@+id/textView3" /&amp;gt;

    &amp;lt;TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="48dp"
        android:layout_marginEnd="20dp"
        android:fontFamily="@font/montserrat_semibold"
        android:onClick="slideUp"
        android:text="Sign in with Huawei"
        android:textColor="@color/colorText"
        android:textSize="48px"
        android:visibility="gone"
        app:layout_constraintEnd_toStartOf="@+id/huaweiLogin"
        app:layout_constraintTop_toBottomOf="@+id/textView4" /&amp;gt;

    &amp;lt;com.huawei.hms.support.hwid.ui.HuaweiIdAuthButton
        android:id="@+id/huaweiLogin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="50dp"
        android:layout_marginEnd="8dp"
        android:onClick="slideUp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView4" /&amp;gt;


    &amp;lt;TextView
        android:id="@+id/registerHereBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="16dp"
        android:fontFamily="@font/montserrat_light"
        android:text="Don't you have an account? Create"
        android:textColor="@color/colorText"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" /&amp;gt;


    &amp;lt;com.huawei.hms.ads.banner.BannerView
        android:id="@+id/hw_banner_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        hwads:adId="testw6vs28auh3"
        hwads:bannerSize="BANNER_SIZE_360_57"
        android:layout_marginStart="8dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="8dp"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView2"/&amp;gt;

&amp;lt;/androidx.constraintlayout.widget.ConstraintLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LBR3-Y86--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pt8fitzlp96zx68alxgl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LBR3-Y86--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pt8fitzlp96zx68alxgl.jpg" alt="Image description" width="880" height="1907"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8rFaodqK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7amj377orejxvwnqxkt.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8rFaodqK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7amj377orejxvwnqxkt.gif" alt="Image description" width="300" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips and Tricks
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Make sure you are already registered as a Huawei developer.&lt;/li&gt;
&lt;li&gt;Set min SDK version to 21 or later, otherwise you will get AndriodManifest to merge issue.&lt;/li&gt;
&lt;li&gt;Make sure you have added the agconnect-services.json file to the app folder.&lt;/li&gt;
&lt;li&gt;Make sure you have added the SHA-256 fingerprint without fail.&lt;/li&gt;
&lt;li&gt;Make sure all the dependencies are added properly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this section, you saw the main flow to integrate the Huawei Account Kit in your mobile application using Android Studio and Java. Other than the Account Kit, HMS core provides a wider range of services to enhance the user experience with the Huawei platform. We have learnt the steps to create projects and steps to integrate the account kit.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://developer.huawei.com/consumer/en/hms/huawei-accountkit/"&gt;Account Kit - Official document&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.huawei.com/consumer/en/codelab/HMSAccounts/index.html#0"&gt;Account Kit - Code lab&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>java</category>
      <category>huawei</category>
      <category>hms</category>
    </item>
  </channel>
</rss>
