Integrate Huawei kits in Online Food ordering app | App Messaging | Analytics kit | JAVA


Online food ordering is process to deliver food from restaurants. In this article will do how to Integrate Huawei Analytics, App-Messaging in food applications.


1. Create App in Android.

2. Configure App in AGC.

3. Integrate the SDK in our new Android project.

4. Integrate the dependencies.

5. Sync project.

Analytics Module

Huawei Analytics will help you understand how people using mobile application. Analytics model help you gain a deeper insight into your user, products and contents.

1. Collect and report custom events.

2. Set a maximum of 25 user attributes

3. Automate event collection and session calculation with predefined event ID’s and parameter.

Use Cases

1. Analyze user behaviour using both predefined and custom events.

2. Use audience building to tailor your marketing activity to your users’ behaviour and preferences.

3. Use dashboards and analytics to measure your marketing activity and identify areas to improve.

Function Restrictions

Device restrictions: The following automatically collected events of analytics kit depend on HMS Core (APK).therefore are not supported on third-party devices where HMS Core is not installed including but not limited to Oppo, Vivo, Xiaomi, Samsung and Oneplus.

Event quantity restriction: Each app can analyze a maximum of 500 events.

Event parameter restrictions: You can define a maximum of 25 parameters for each event, and maximum of 100 event parameter for each app.

AGC Configuration

1. Create an app adding an app to the project.

2. Enable Analytics Choose My Projects> Huawei Analytics

3. Enable Analytics Api Choose My Projects>Project settings>Manage APIs


Create Application in Android Studio.

App level gradle dependencies.

apply plugin: ‘’
apply plugin: ‘com.huawei.agconnect’

Gradle dependencies

implementation ‘com.huawei.hms:hianalytics:’

Root level gradle dependencies

maven {url ‘'}

classpath ‘com.huawei.agconnect:agcp:’

1. Create Instance for HiAnalyticsInstance in the onCreate method

HiAnalyticsInstance instance = HiAnalytics.getInstance(this);

2. Create method for report an event.

private void reportevent() {Bundle bundle = new Bundle();bundle.putString("Name", signInResult.getUser().getDisplayName());mInstance.onEvent("SIGNIN", bundle);


App Messaging Module

Huawei App messaging is one of the power full tool we can promotes information to audience. This will help you to when you are trying to get more attention to your application. We can target users actively using this application to encourage them to use this app.

App Messaging even allows you to customize how your messages look and the way they will be sent, and define events for triggering message sending to your users at the right moment.

Message Types

1. Pop-up Message: Title and body and contain an image and up to two buttons.

2. Banner Message: Message is displayed on top of the screen, containing a thumbnail and the message title and body. user can tap the banner to access specified page

3. Image: It contains only image. An image message can be a poster well designed to promote an activity. User can tap the image to access the activity details.

AGC Configuration

  1. Enable App Messaging Api Choose My Projects>Project settings>Manage Apis

2. Enable App Messaging Choose My Projects>Growing>App Messaging Click Enable Now

3. Click New Button fill required information.

4. Enter required details then click Next Button.

5. Select Sending Target section Here we can define Condition for matching target users. Select required conditions then click Next Button

6. Set Sending Time Here we can set Schedule or Now message delivery to users. Select required Trigger event, Frequency limit then click Next Button.

7. Once all the required information filled then click Save Button

8. Go to Operation tab then click Test option to perform the app Messaging publishing


Gradle dependencies

implementation ‘com.huawei.agconnect:agconnect-appmessaging:’

1. Generate AAID, this AAID will help you to sending App-Messages.

private void generateAAID(){
HmsInstanceId inst = HmsInstanceId.getInstance(this);
Task<AAIDResult> idResult = inst.getAAID();
idResult.addOnSuccessListener(aaidResult -> Log.d(“AAID”, “getAAID success:” + aaidResult.getId() ))
.addOnFailureListener(e -> Log.d(“AAID”, “getAAID failure:” + e));

2. For displaying messages we need to call AGConnectAppMessaging Instance.

3. setFetchMessageEnable() To allow data synchronization from the app gallery connect server.

4. setDisplayEnable() To Enable message display.

5. setForceFetch() To specify that the in-app message data must be obtained from App Gallery connect server.

private void initializeInAppMessage(){
AGConnectAppMessaging appMessaging = AGConnectAppMessaging.getInstance();



In this Article, I have explained how to integrate App Messaging and Analytics Kit on food application.


Analytics kit:

App Messaging: