Browse Source

集成友盟统计SDK

shuij 3 years ago
parent
commit
2d17e9d813

+ 3 - 0
app/build.gradle

@@ -80,6 +80,9 @@ dependencies {
     implementation deps.permisson
     implementation deps.basePopup
     implementation deps.smartTable
+    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() {

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -20,7 +20,7 @@
         android:name="com.uas.pda_smart_com.application.PdaApplication"
         android:allowBackup="true"
         android:icon="@mipmap/icon"
-        android:label="@string/my_app_name"
+        android:label="@string/my_app_name_test"
         android:theme="@style/AppTheme"
         android:usesCleartextTraffic="true"
         tools:replace="icon,label,theme">

+ 27 - 0
app/src/main/java/com/uas/pda_smart_com/application/PdaApplication.java

@@ -13,6 +13,8 @@ import com.uas.pda_smart_com.R;
 import com.uas.pda_smart_com.util.AndroidUtil;
 import com.uas.pda_smart_com.util.FakeX509TrustManager;
 import com.uas.pda_smart_com.util.SoundUtil;
+import com.umeng.analytics.MobclickAgent;
+import com.umeng.commonsdk.UMConfigure;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -82,6 +84,31 @@ 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));
+        //友盟统计SDK
+        initUmeng();
+    }
+
+
+    private void initUmeng() {
+        //2.在Application.oncreate()中调用预初始化函数
+        UMConfigure.preInit(this, "6170b8b61c91e0671bb0da5a","umeng");
+        UMConfigure.setLogEnabled(true);
+        //3.客户端用户同意隐私政策后,正式初始化友盟+SDK
+        UMConfigure.init(
+                this,
+                "6170b8b61c91e0671bb0da5a",
+                "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

+ 0 - 1
app/src/main/java/com/uas/pda_smart_com/fragment/StorageRechargeFragment.java

@@ -511,7 +511,6 @@ public class StorageRechargeFragment extends BaseFragment implements View.OnClic
                         storageRechargeListBean.setQuantity(FastjsonUtil.getDouble(detailObject, "AND_INQTY"));
                         storageRechargeListBean.setDetail(FastjsonUtil.getText(detailObject, "PR_DETAIL"));
                         storageRechargeListBean.setSpec(FastjsonUtil.getText(detailObject, "PR_SPEC"));
-
                         mStorageRechargeListBeans.add(storageRechargeListBean);
                     }
                 }