Home >Backend Development >PHP Tutorial >Add Umeng statistics to Android applications_PHP tutorial
Umeng is a mobile application statistical analysis platform. It can help mobile application operators count and analyze traffic sources, product retention data, user attributes and behavior data, etc., so that product developers and operators can use the data to make decisions on products, operations, and promotion strategies.
First go to Umeng official website http://www.umeng.com/ to register an account. After completion, go to the management background to add applications that need to integrate Umeng statistics, as follows
After submission, assign a key to your application, as follows
Next go to http://dev .umeng.com/analytics/android-doc/sdk-downloadDownload the SDK, copy the jar file in libs in the downloaded folder to the libs in the project, right-click the jar file in Android Studio, and select Add as library completes the import.
Add the corresponding permissions, as follows
<code class="language-none" style="-webkit-print-color-adjust:exact;margin:0px;padding:0px;border:none;border-radius:3px;background-color:transparent;"><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><uses-permission android:name="android.permission.INTERNET"></uses-permission><uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission></code>
Then fill in the key and channel id. Only one channel can be added to a package, as follows
<code class="language-none" style="-webkit-print-color-adjust:exact;margin:0px;padding:0px;border:none;border-radius:3px;background-color:transparent;"><meta-data android:value="这里填写友盟分配的key值" android:name="UMENG_APPKEY"></meta-data><meta-data android:value="这里填写渠道名称,如Wandoujia或者360" android:name="UMENG_CHANNEL"></meta-data></code>
在每个Activity的onResume方法中调用MobclickAgent.onResume(Context),在onPause方法中调用MobclickAgent.onPause(Context)。如果Activity之间有继承关系,不要重复添加onResume和onPause方法,否则会出现重复统计,影响统计结果。如果App中有调用Process.kill或者System.exit之类的方法杀死进程,请务必在此之前调用MobclickAgent.onKillProcess(Context)方法,用来保存统计数据。
至此,基本功能已经集成完毕,还是很简单的。后续的一些高级功能,可以根据自己的需求另行添加,官方的文档已经写得很详细了,这里就不再写了,感兴趣的去友盟的官网查看。
1、http://www.umeng.com/
2、http://dev.umeng.com/analytics/android-doc/integration