mirror of
https://github.com/markusfisch/BinaryEye.git
synced 2024-09-19 19:42:18 +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:
parent
a03a187d2d
commit
49af17cba8
@ -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
|
||||
startActivityAndCollapse(intent)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user