android友盟统计的使用

1.依赖

根Build.gradle
添加:maven { url ‘https://repo1.maven.org/maven2/’ }
全部代码,包含阿里云

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        maven { url 'https://repo1.maven.org/maven2/' }
        maven{ url 'https://maven.aliyun.com/repository/central'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/spring'}
        maven{ url 'https://maven.aliyun.com/repository/spring-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/grails-core'}
        maven{ url 'https://maven.aliyun.com/repository/apache-snapshots'}

        maven { url "https://dl.bintray.com/thelasterstar/maven/" }
        maven { url 'https://dl.bintray.com/umsdk/release' }
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.3"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        maven { url 'https://repo1.maven.org/maven2/' }
        maven{ url 'https://maven.aliyun.com/repository/central'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/spring'}
        maven{ url 'https://maven.aliyun.com/repository/spring-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/grails-core'}
        maven{ url 'https://maven.aliyun.com/repository/apache-snapshots'}

        maven { url "https://dl.bintray.com/thelasterstar/maven/" }
        maven { url 'https://dl.bintray.com/umsdk/release' }
        google()
        jcenter()
        maven { url "http://lib.gcssloop.com:8081/repository/gcssloop-central/" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
   // 友盟统计SDK
    implementation  'com.umeng.umsdk:common:9.4.0'// 必选
    implementation  'com.umeng.umsdk:asms:1.2.3'// 必选
    implementation 'com.umeng.umsdk:apm:1.3.1' // 错误分析升级为独立SDK,看crash数据请一定集成,可选
    implementation  'com.umeng.umsdk:abtest:1.0.0'//使用U-App中ABTest能力,可选

2.在application添加key

其中key是自己申请的key(例子:5433fert35t532)
冷启动

//友盟统计
        // 初始化SDK appkey在官方注册应用即可获取
        //按规定,这里用冷启动,既要同意了,执行Init才开始统计,不然不统计
        //参数介绍:第一个是上下文,第二个是友盟可以,第三个是打包渠道,这里可以多渠道打包,没有的话
        UMConfigure.preInit(this,BuildConfig.umeng_app_Key,BuildConfig.URL);

用户点击同意后,执行真正的 统计

UMConfigure.init(HdztwelcomeActivity.this, BuildConfig.umeng_app_Key, BuildConfig.URL, UMConfigure.DEVICE_TYPE_PHONE, null);

3.再baseActivity里的onResume,onPause写东西

@Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值