gpt4 book ai didi

java - 定位 S+(版本 31 及更高版本)需要指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一

转载 作者:行者123 更新时间:2023-12-04 23:36:09 26 4
gpt4 key购买 nike

应用程序在运行时崩溃并出现以下错误:

java.lang.IllegalArgumentException: maa.abc: TargetingS+ (version 31 and above) requires that one of FLAG_IMMUTABLE orFLAG_MUTABLE be specified when creating a PendingIntent.Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. ifit needs to be used with inline replies or bubbles.at android.app.PendingIntent.checkFlags(PendingIntent.java:375)at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)at com.google.android.exoplayer2.ui.PlayerNotificationManager.createBroadcastIntent(PlayerNotificationManager.java:1373)at com.google.android.exoplayer2.ui.PlayerNotificationManager.createPlaybackActions(PlayerNotificationManager.java:1329)at com.google.android.exoplayer2.ui.PlayerNotificationManager.(PlayerNotificationManager.java:643)at com.google.android.exoplayer2.ui.PlayerNotificationManager.(PlayerNotificationManager.java:529)at com.google.android.exoplayer2.ui.PlayerNotificationManager.createWithNotificationChannel(PlayerNotificationManager.java:456)at com.google.android.exoplayer2.ui.PlayerNotificationManager.createWithNotificationChannel(PlayerNotificationManager.java:417)


我尝试了所有可用的解决方案,但该应用程序仍然在 Android 12 上崩溃。
 @Nullable
@Override
public PendingIntent createCurrentContentIntent(@NonNull Player player) {
Intent intent = new Intent(service, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
return PendingIntent.getActivity(service, 0, intent,PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);

}

最佳答案

如果使用 java 或 react-native 然后将其粘贴到 app/build.gradle

dependencies {
// ...
implementation 'androidx.work:work-runtime:2.7.1'
}

如果使用 Kotlin,那么使用这个

dependencies {
// ...
implementation 'androidx.work:work-runtime-ktx:2.7.0'
}

如果有人仍然面临 android 12 的崩溃问题,请确保在 AndroidMenifest.xml 中添加以下内容

 <activity 
...
android:exported="true" // in most cases it is true but based on requirements it can be false also
>


// If using react-native push notifications then make sure to add into it also

<receiver
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" android:exported="true">

// Similarly

<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="true">

关于java - 定位 S+(版本 31 及更高版本)需要指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70894168/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com