Skip to content

Commit

Permalink
Merge pull request #81 from GuoXiCheng/dev
Browse files Browse the repository at this point in the history
add delete apk
  • Loading branch information
GuoXiCheng authored Nov 7, 2023
2 parents fe45245 + ebf328e commit 09d5135
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
env:
LATEST_VERSION: "1.4.3"
LATEST_VERSION: "1.4.4"

jobs:
build-and-deploy:
Expand Down
Binary file added apk/SKIP-v1.4.4.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk 24
targetSdk 32
versionCode 1
versionName "1.4.3"
versionName "1.4.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
18 changes: 15 additions & 3 deletions app/src/main/java/com/android/skip/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.android.skip

import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.*
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -256,12 +254,26 @@ class MainActivity : ComponentActivity() {
apkFile
)

// 创建并注册 BroadcastReceiver
val receiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_PACKAGE_ADDED) {
// 删除 APK 文件
apkFile.delete()
}
}
}
registerReceiver(receiver, IntentFilter(Intent.ACTION_PACKAGE_ADDED))

val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(apkUri, "application/vnd.android.package-archive")
intent.flags =
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
this.startActivity(intent)

// 取消注册 BroadcastReceiver
unregisterReceiver(receiver)

isUpdateAPKClicked = false
}
}
Expand Down

0 comments on commit 09d5135

Please sign in to comment.