Home > Backend Development > PHP Tutorial > Add Umeng statistics to Android applications_PHP tutorial

Add Umeng statistics to Android applications_PHP tutorial

WBOY
Release: 2016-07-12 09:03:54
Original
1148 people have browsed it

Add Umeng statistics to Android application

Software and hardware environment

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

Foreword

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.

Integrate Umeng SDK

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

Add Umeng statistics to Android applications_PHP tutorial

After submission, assign a key to your application, as follows

Add Umeng statistics to Android applications_PHP tutorial

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.

Configure AndroidManifest.xml

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>
Copy after login

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>
Copy after login

集成代码

在每个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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1077806.htmlTechArticleAndroid应用中添加友盟统计 软硬件环境 Macbook Pro MGX 72 Android Studio 1.3.2 Genymotion模拟器 前言 友盟是一款移动应用统计分析平台。它可以帮助移...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template