Xamarin(Android) Application using Analytics Kit
Overview
This application uses Analytics Kit in Xamarin Android application. Using Analytics Kit, we can keep track of user’s activity. This will help in showing ad’s related to specific user on top most visiting screen and can make profit.
Huawei Analytics Kit
Huawei Analytics Kit provides information regarding user’s activity, products and contents. With this we can market our apps and improve our products. We can also track and report on custom events as well as automate event collection and session calculation.
Let us start with the implementation part:
Step 1: Create an app on App Gallery Connect and enable the analytics service. Follow the link.
Step 2: Create project in Xamarin and integrate libraries.
Follow the link:
You can use below link for downloading the libraries:
https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/hms-analytics-xamarin-libbinding
Step 3: Download agconnect-services.json from App Information Section. Copy and paste the Json file in the Asset folder of the Xamarin project.
Step 4: Now build the project.
Step 5: Create a new class for reading agconnect-services.json file.
Step 6: Create a custom content provider class to read agconnect-services.json file before the application starts up.
Step 7: Add below permission in Manifest.xml.
Step 8: Generate SHA 256 key from app and add it to your App Gallery project.
Step 9: Initialize Huawei Analytics and enable it. Write below code in MainActivity.cs onCreate() method.
Step 10: Use below code to send custom events.
Now implementation part done. To see the info on app’s analytics, you need to enable app debugging using below command.
adb shell setprop debug.huawei.hms.analytics.app <package_name>
Result:






Tips and Tricks
- Do not forget to enable app debugging otherwise you can’t see the data.
- Please add all libraries properly.
Conclusion
Using Huawei Analytics Kit, we can monetize our app and make profit after showing ads on particular screen. This will help us to keep track of user’s activity while using the app.
Reference