安卓中通用的工具库,自用
api 'com.townwang:common:x.x.x' //x.x.x 换成最新版本
在Appliction 初始化
KeepLive.startWork(this, KeepLive.RunMode.ROGUE, ForegroundNotification("进程保活", "正在运行...",
R.mipmap.ic_launcher, object : ForegroundNotificationClickListener {
override fun foregroundNotificationClick(context: Context, intent: Intent) {
//点击通知回调
}
}), object : KeepLiveService {
override fun onStop() {
//可能调用多次,跟onWorking匹配调用
}
override fun onWorking() {
//一直存活,可能调用多次
}
})
- 在更新Activity初始化
UpdateHelper.VersionInfo(this)
.setUrl("https://townwang.com/town.apk") //app下载地址
.setNewVersion("1.0.1")// 版本号 或者 setNewVersionCode 版本Code
.setForce(true) //s是否强制更新 默认非强制
.build()