make build working with target sdk 31

This commit is contained in:
Holger Müller 2022-04-08 23:21:15 +02:00
parent 5890c32b7e
commit 7a8f20ade7
3 changed files with 6 additions and 5 deletions

View File

@ -17,6 +17,7 @@ package org.moire.ultrasonic.playback
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Intent import android.content.Intent
import android.os.Build
import androidx.media3.common.AudioAttributes import androidx.media3.common.AudioAttributes
import androidx.media3.common.C import androidx.media3.common.C
import androidx.media3.common.C.CONTENT_TYPE_MUSIC import androidx.media3.common.C.CONTENT_TYPE_MUSIC
@ -138,7 +139,7 @@ class PlaybackService : MediaLibraryService(), KoinComponent {
val intent = Intent(this, NavigationActivity::class.java) val intent = Intent(this, NavigationActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
var flags = PendingIntent.FLAG_UPDATE_CURRENT var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// needed starting Android 12 (S = 31) // needed starting Android 12 (S = 31)
flags = flags or PendingIntent.FLAG_IMMUTABLE flags = flags or PendingIntent.FLAG_IMMUTABLE
} }

View File

@ -13,6 +13,7 @@ import android.appwidget.AppWidgetProvider
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.Environment import android.os.Environment
import android.view.KeyEvent import android.view.KeyEvent
import android.widget.RemoteViews import android.widget.RemoteViews
@ -172,7 +173,7 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() {
intent.action = "android.intent.action.MAIN" intent.action = "android.intent.action.MAIN"
intent.addCategory("android.intent.category.LAUNCHER") intent.addCategory("android.intent.category.LAUNCHER")
var flags = PendingIntent.FLAG_UPDATE_CURRENT var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// needed starting Android 12 (S = 31) // needed starting Android 12 (S = 31)
flags = flags or PendingIntent.FLAG_IMMUTABLE flags = flags or PendingIntent.FLAG_IMMUTABLE
} }
@ -189,7 +190,7 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() {
KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE)
) )
flags = 0 flags = 0
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// needed starting Android 12 (S = 31) // needed starting Android 12 (S = 31)
flags = flags or PendingIntent.FLAG_IMMUTABLE flags = flags or PendingIntent.FLAG_IMMUTABLE
} }

View File

@ -7,7 +7,6 @@
package org.moire.ultrasonic.service package org.moire.ultrasonic.service
import android.annotation.SuppressLint
import android.app.Notification import android.app.Notification
import android.app.NotificationChannel import android.app.NotificationChannel
import android.app.NotificationManager import android.app.NotificationManager
@ -158,7 +157,7 @@ class DownloadService : Service() {
val intent = Intent(this, NavigationActivity::class.java) val intent = Intent(this, NavigationActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
var flags = PendingIntent.FLAG_UPDATE_CURRENT var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// needed starting Android 12 (S = 31) // needed starting Android 12 (S = 31)
flags = flags or PendingIntent.FLAG_IMMUTABLE flags = flags or PendingIntent.FLAG_IMMUTABLE
} }