Add umeng statistics to Android applications

Source: Internet
Author: User

Add umeng statistics to Android applications
Software and hardware environment

  • Macbook Pro MGX 72
  • Android Studio 1.3.2
  • Genymotion Simulator
Preface

Umeng is a mobile application statistical analysis platform. It helps mobile app operators to collect statistics and analyze traffic sources, product retention data, user attributes, and behavior data, this allows product developers and operators to use data to make decisions on products, operations, and promotion strategies.

Integrate umeng SDK

First, go to the umeng official website http://www.umeng.com/register an account. After completing the registration, go to the management background to integrate the application of umeng statistics, as shown below:

After submission, assign the key to your application as follows:

Right-click the jar file in development Studio and select Add as library to complete the import.

Configure AndroidManifest. xml

Add the following permissions:

<uses-sdk android:minSdkVersion="4"></uses-sdk><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.INTERNET"></uses-permission><uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>

Enter the key and channel id. Only one channel can be added to a package, as shown below:

<Meta-data android: value = "Enter the key value allocated by umeng" android: name = "UMENG_APPKEY"/> <meta-data android: value = "Enter the channel name here, such as Wandoujia or 360 "android: name =" UMENG_CHANNEL "/>
Integration code

Call MobclickAgent. onResume (Context) in the onResume method of each Activity, and call MobclickAgent. onPause (Context) in the onPause method ). If there is an inheritance relationship between activities, do not add the onResume and onPause methods repeatedly. Otherwise, repeated statistics will appear, affecting the statistical results. If the App calls methods such as Process. kill or System. exit to kill a Process, call the MobclickAgent. onKillProcess (Context) method before killing the Process.

At this point, the basic functions have been integrated, and it is still very simple. Some of the subsequent advanced functions can be added as needed. The official documents are already detailed and will not be written here. If you are interested, go to umeng's official website to view them.

References

1. http://www.umeng.com/
2. http://dev.umeng.com/analytics/android-doc/integration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.