Selaa lähdekoodia

友盟SDK集成

shuij 4 vuotta sitten
vanhempi
commit
7ddb8ef811

+ 3 - 0
app/build.gradle

@@ -85,6 +85,9 @@ dependencies {
     implementation deps.permisson
     implementation deps.smartTable
     implementation deps.basePopup
+    implementation  'com.umeng.umsdk:common:9.4.0'// 必选
+    implementation  'com.umeng.umsdk:asms:1.2.3'// 必选
+    implementation 'com.umeng.umsdk:apm:1.4.0' // 错误分析升级为独立SDK,看crash数据请一定集成,可选
 }
 
 def getVersionName() {

+ 24 - 0
app/src/main/java/com/uas/pda_wms/application/PdaApplication.java

@@ -13,6 +13,8 @@ import com.uas.pda_wms.R;
 import com.uas.pda_wms.util.AndroidUtil;
 import com.uas.pda_wms.util.FakeX509TrustManager;
 import com.uas.pda_wms.util.SoundUtil;
+import com.umeng.analytics.MobclickAgent;
+import com.umeng.commonsdk.UMConfigure;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -82,6 +84,28 @@ public class PdaApplication extends Application {
         mSoundMap.put(SoundUtil.SOUND_SALACIA, mSoundPool.load(this, R.raw.salacia, 1));
         mSoundMap.put(SoundUtil.SOUND_TETHYS, mSoundPool.load(this, R.raw.tethys, 1));
         mSoundMap.put(SoundUtil.SOUND_TITAN, mSoundPool.load(this, R.raw.titan, 1));
+        initUmeng();
+    }
+
+    private void initUmeng() {
+        //2.在Application.oncreate()中调用预初始化函数
+        UMConfigure.preInit(this, "61962522d8b17762e81889f8","umeng");
+        UMConfigure.setLogEnabled(true);
+        //3.客户端用户同意隐私政策后,正式初始化友盟+SDK
+        UMConfigure.init(
+                this,
+                "61962522d8b17762e81889f8",
+                "umeng",
+                UMConfigure.DEVICE_TYPE_PHONE, ""
+        );
+        // 页面数据采集模式
+        // setPageCollectionMode接口参数说明:
+        // 1. MobclickAgent.PageMode.AUTO: 建议大多数用户使用本采集模式,SDK在此模式下自动采集Activity
+        // 页面访问路径,开发者不需要针对每一个Activity在onResume/onPause函数中进行手动埋点。在此模式下,
+        // 开发者如需针对Fragment、CustomView等自定义页面进行页面统计,直接调用MobclickAgent.onPageStart/
+        // MobclickAgent.onPageEnd手动埋点即可。此采集模式简化埋点工作,唯一缺点是在Android 4.0以下设备中
+        // 统计不到Activity页面数据和各类基础指标(提示:目前Android 4.0以下设备市场占比已经极小)。
+        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
     }
 
     @Override