
[英]Getting android.app.ForegroundServiceStartNotAllowedException in Android 12 (SDK 31)
[英]Android 12: SDK(31) unable to launch activity using intents
这是代码 -
if (Build.VERSION.SDK_INT >= 31) {
Intent intent=new Intent(launcher.this,MainActivity.class);
startActivity(intent);
finish();
}
我收到此错误-控制台错误-
定位 S+(版本 31 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一。 强烈考虑使用 FLAG_IMMUTABLE,仅当某些功能依赖于 PendingIntent 是可变的时才使用 FLAG_MUTABLE,例如,如果它需要与内联回复或气泡一起使用。 在 android.app.PendingIntent.checkFlags(PendingIntent.java:375)
未决意图可变性标志错误不一定是引发堆栈跟踪的位置(根据经验),请尝试搜索您的任何代码的项目使用未决意图而不设置可变性标志。
只需将此库添加到您的 gradle...
implementation 'androidx.work:work-runtime-ktx:2.7.0-alpha05'
为我工作...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.