0
0
mirror of https://github.com/markusfisch/BinaryEye.git synced 2024-09-20 03:52:16 +02:00

Fix quick setting tile failed to launch on Android 14

SDK 34 deprecates startActivityAndCollapse(Intent), making it
throws an UnsupportedOperationException on Android 14 devices
instead of launching the app.

Added new function call for API 34, tested with Android 14 and
Android 9 devices.
This commit is contained in:
v72807647 2023-11-22 16:24:30 +08:00 committed by GitHub
parent a03a187d2d
commit 49af17cba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package de.markusfisch.android.binaryeye.service
import android.app.PendingIntent
import android.content.Intent
import android.os.Build
import android.service.quicksettings.TileService
@ -12,6 +13,17 @@ class ScanTileService : TileService() {
super.onClick()
val intent = Intent(applicationContext, CameraActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
@Suppress("DEPRECATION")
startActivityAndCollapse(intent)
} else {
val pendingIntent = PendingIntent.getActivity(
this,
0,
intent,
PendingIntent.FLAG_IMMUTABLE
)
startActivityAndCollapse(pendingIntent)
}
}
}