欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

android友盟统计的使用

发布时间:2023/12/20 编程问答 29 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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 } // 友盟统计SDKimplementation '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写东西

@Overrideprotected void onResume() {super.onResume();MobclickAgent.onResume(this);}@Overrideprotected void onPause() {super.onPause();MobclickAgent.onPause(this);}

总结

以上是生活随笔为你收集整理的android友盟统计的使用的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。