|
|
@@ -0,0 +1,141 @@
|
|
|
+package org.cocos2dx.javascript.thirdSdk.umeng;
|
|
|
+
|
|
|
+import android.app.Activity;
|
|
|
+import android.app.Application;
|
|
|
+import android.content.Context;
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
+import com.aries.qsllx.mz.BuildConfig;
|
|
|
+import com.umeng.analytics.MobclickAgent;
|
|
|
+import com.umeng.commonsdk.UMConfigure;
|
|
|
+
|
|
|
+import java.security.PublicKey;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public class UMSDKMgr {
|
|
|
+
|
|
|
+ /** 单例模式*/
|
|
|
+ private static UMSDKMgr mInstace = null;
|
|
|
+
|
|
|
+ public static UMSDKMgr getInstance() {
|
|
|
+ if (null == mInstace) {
|
|
|
+ mInstace = new UMSDKMgr();
|
|
|
+ }
|
|
|
+ return mInstace;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Application myApplication = null;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * appkey和channel参数必须和后续调用的UMConfigure.init初始化函数appkey、channel参数值一致。
|
|
|
+ */
|
|
|
+ public void _UMPREInit() {
|
|
|
+ UMConfigure.preInit(myApplication, BuildConfig.UM_AID, BuildConfig.UM_CHANNEL);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void _UMSDKInit() {
|
|
|
+ if (this.myApplication == null) {
|
|
|
+ Log.e("UMSDKMgr", "appActivity is null !!!!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ UMConfigure.init(myApplication,
|
|
|
+ BuildConfig.UM_AID, BuildConfig.UM_CHANNEL, UMConfigure.DEVICE_TYPE_PHONE, BuildConfig.UM_SECRET);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void _UMSDKLogin(String v) {
|
|
|
+ MobclickAgent.onProfileSignIn(v);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void _UMSDKLogout() {
|
|
|
+ MobclickAgent.onProfileSignOff();
|
|
|
+ }
|
|
|
+
|
|
|
+ //开启自动统计日活,新增
|
|
|
+ public void _UMSDKStartAuto() {
|
|
|
+ MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ //开启手动统计,需要在Activity的onResume/onPause函数中手动调用
|
|
|
+ // MobclickAgent.onResume/MobclickAgent.onPause函数,
|
|
|
+ // 保证正确统计应用使用时长、启动、活跃等基础指标
|
|
|
+ public void _UMSDKStartManual() {
|
|
|
+ MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.MANUAL);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计OnResume
|
|
|
+ */
|
|
|
+ public void _UMOnResume(Context context) {
|
|
|
+ MobclickAgent.onResume(context);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计OnPasue
|
|
|
+ */
|
|
|
+ public void _UMOnPause(Context context) {
|
|
|
+ MobclickAgent.onPause(context);
|
|
|
+ }
|
|
|
+
|
|
|
+ //支持在子进程中统计自定义事件,默认关闭
|
|
|
+ public void _UMSDKProcessEvent() {
|
|
|
+ UMConfigure.setProcessEvent(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ event id长度不能超过128个字节,key不能超过128个字节,value不能超过256个字节
|
|
|
+ id、ts、du、token、device_name、device_model 、device_brand、country、city、channel、province、
|
|
|
+ appkey、app_version、access、launch、pre_app_version、terminate、no_first_pay、
|
|
|
+ is_newpayer、first_pay_at、first_pay_level、first_pay_source、
|
|
|
+ first_pay_user_level、first_pay_versio是保留字段,不能作为event id 及key的名称;
|
|
|
+ 如需要统计支付金额、使用时长等数值型的连续变量,请使用计算事件
|
|
|
+ (不允许通过key-value结构来统计类似搜索关键词,网页链接等随机生成的字符串信息)
|
|
|
+ */
|
|
|
+
|
|
|
+ //普通事件
|
|
|
+ public void _UMSDKEventId(Context context, String eventID) {
|
|
|
+ MobclickAgent.onEvent(context, eventID);
|
|
|
+ }
|
|
|
+
|
|
|
+ //友盟事件
|
|
|
+ public void _UMSDKEvent(Context context, String eventID, String des)
|
|
|
+ {
|
|
|
+ Log.d("_UMSDKEvent", "eventId"+eventID+" " + "des" + des );
|
|
|
+ Map<String, String> data = new HashMap<String,String>();
|
|
|
+ data.put("eventID", eventID);
|
|
|
+ data.put("des", des);
|
|
|
+ MobclickAgent.onEvent(context, eventID, data);
|
|
|
+ }
|
|
|
+
|
|
|
+ //带标签的事件
|
|
|
+ public void _UMSDKEventLabel(Context context, String eventID, String label) {
|
|
|
+ Log.d("_UMSDKEventLabel", "aaaaaaaaaa ");
|
|
|
+ MobclickAgent.onEvent(context, eventID, label);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 统计点击行为各属性被触发的事件
|
|
|
+ HashMap<String,String> map = new HashMap<String,String>();
|
|
|
+ map.put("type","book");
|
|
|
+ map.put("quantity","3");
|
|
|
+ UMSDKHelper.getInstance()._UMSDKEventMap(context,"xxx",map);
|
|
|
+ */
|
|
|
+ public void _UMSDKEventMap(Context context, String eventID, Map<String, String> map) {
|
|
|
+ MobclickAgent.onEvent(context, eventID, map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 统计点击行为各属性被触发的事件.带参数类型:String,Integer,Long,Short,Float,Double
|
|
|
+ Map<String, Object> music = new HashMap<String, Object>();
|
|
|
+ music.put("music_type", "popular");//自定义属性:音乐类型,值:流行
|
|
|
+ music.put("singer", "JJ"); //歌手:(林俊杰)JJ
|
|
|
+ music.put("song_name","A_Thousand_Years_Later"); //歌名:一千年以后
|
|
|
+ UMSDKHelper.getInstance()._UMSDKEventMap(context,"xxx",music);
|
|
|
+ */
|
|
|
+ public void _UMSDKEventObject(Context context, String eventID, Map<String, Object> map) {
|
|
|
+ MobclickAgent.onEventObject(context, eventID, map);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|