埋码改进

package com.gome.ecmall.util;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;

import com.gome.ecmall.app.AppConfig;
import com.gome.ecmall.bean.GlobalConfig;
import com.gome.eshopnew.R;
import com.omniture.AppMeasurement;

/**
* 数据统计--工具类 获取一个统计实例 ,并初始化常用的参数
*
* @param context
* @return 一个新的,带有基本参数的统计实例
*  注意: 只能接受从activity过来的调用
*/
public class MeasurementUtils {
    public static AppMeasurement s;
    private static final MeasurementUtils instance = new MeasurementUtils();
    private MeasurementUtils(){
    }
   
    public static MeasurementUtils getInstance(Context context){
        s = new AppMeasurement(((Activity) context).getApplication());

        // *******************公共属性Start*******************

        // 数据统计环境
        if (AppConfig.APP_MEASUREMENT_PRODUCT) {
            s.account = "gome-app";
        } else {
            s.account = "gome-app-dev";
        }
        s.trackingServer = "gome.122.2o7.net";
        // 币种代码
        s.currencyCode = "CNY";
        s.visitorNamespace = "gome";
        if (GlobalConfig.isLogin) {
            s.eVar14 = GlobalConfig.getInstance().getUserId();
            s.eVar20 = GlobalConfig.getInstance().getUserName();
        }
        // Android系统版本
        s.eVar21 = MobileDeviceUtil.getInstance(context.getApplicationContext()).getSystemVersion();
        // 手机系统信息
        s.eVar22 = MobileDeviceUtil.getInstance(context.getApplicationContext()).getOperator();
        // 软件版本编号
        s.eVar23 = MobileDeviceUtil.getInstance(context.getApplicationContext()).getVersonName();
        // IMEI
        s.eVar24 = MobileDeviceUtil.getInstance(context.getApplicationContext()).getMobileImei();
        // 网络类型
        s.eVar25 = MobileDeviceUtil.getNetType(context.getApplicationContext());
        // UUID
        s.eVar26 = MobileDeviceUtil.getInstance(context.getApplicationContext()).getUUID();
        // 渠道名称
        s.eVar28 = MobileDeviceUtil.getInstance(context.getApplicationContext()).getChannalName();
        // MAC地址
        s.eVar29 = MobileDeviceUtil.getInstance(context.getApplicationContext()).getMacAddress();
        // 设备类型
        s.eVar36 = "Android";
        return instance;
    }
    public void track(){
        if (AppConfig.OPEN_APPMEASUREMENT) {
        s.track();
        }
    }
public void trackLink(String linkURL, String linkType, String linkName){
    if (AppConfig.OPEN_APPMEASUREMENT) {
    s.trackLink(linkURL, linkType, linkName);
        }
    }


使用方法:
MeasurementUtils  mUtil =  MeasurementUtils.getInstance();
mUtil.s.var39="xxxxxx";
mUtil.track();

你可能感兴趣的:(埋码改进)