Skip to content

Commit

Permalink
api升级34 适配android14
Browse files Browse the repository at this point in the history
  • Loading branch information
puyang1017 committed Aug 20, 2024
1 parent 63ce04f commit 29fac31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions updateapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 30
compileSdkVersion 34


defaultConfig {
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 34
versionCode 1
versionName "1.0"

Expand Down
13 changes: 11 additions & 2 deletions updateapp/src/main/kotlin/updateapp/update/UpdateAppService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package update
import android.app.Service
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.os.IBinder
import android.content.Context.RECEIVER_EXPORTED

/**
* desc: UpdateAppService
Expand All @@ -15,8 +17,15 @@ internal class UpdateAppService : Service() {
override fun onCreate() {
super.onCreate()
// 动态注册receiver 适配8.0 updateAppReceiver 静态注册没收不到广播
registerReceiver(updateAppReceiver, IntentFilter(packageName + UpdateAppReceiver.ACTION_UPDATE))
registerReceiver(updateAppReceiver, IntentFilter(packageName + UpdateAppReceiver.ACTION_RE_DOWNLOAD))

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
registerReceiver(updateAppReceiver, IntentFilter(packageName + UpdateAppReceiver.ACTION_UPDATE), RECEIVER_EXPORTED)
registerReceiver(updateAppReceiver, IntentFilter(packageName + UpdateAppReceiver.ACTION_RE_DOWNLOAD), RECEIVER_EXPORTED)
}else {
registerReceiver(updateAppReceiver, IntentFilter(packageName + UpdateAppReceiver.ACTION_UPDATE))
registerReceiver(updateAppReceiver, IntentFilter(packageName + UpdateAppReceiver.ACTION_RE_DOWNLOAD))
}

}

override fun onDestroy() {
Expand Down

0 comments on commit 29fac31

Please sign in to comment.