iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >【已解决】Android12以上PendingIntent需要强制增加FLAG_IMMUTABLE或FLAG_MUTABLE
  • 761
分享到

【已解决】Android12以上PendingIntent需要强制增加FLAG_IMMUTABLE或FLAG_MUTABLE

androidPoweredby金山文档 2023-09-01 10:09:17 761人浏览 八月长安
摘要

Android13适配时报下面错误: java.lang.IllegalArgumentException: android: Targeting S+ (version 31 and above) requires that one o

Android13适配时报下面错误:

java.lang.IllegalArgumentException: android: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

02-26 20:00:47.055 27821 27821 I System  : java.lang.IllegalArgumentException: android: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.02-26 20:00:47.055 27821 27821 I System  : Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.02-26 20:00:47.055 27821 27821 I System  :     at android.app.PendingIntent.checkFlags(PendingIntent.java:404)02-26 20:00:47.055 27821 27821 I System  :     at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:674)02-26 20:00:47.055 27821 27821 I System  :     at android.app.PendingIntent.getBroadcast(PendingIntent.java:661)02-26 20:00:47.055 27821 27821 I System  :     at com.XX.server.ntp.SunmiNetworkTimeUpdateService.(SunmiNetworkTimeUpdateService.java:148)02-26 20:00:47.055 27821 27821 I System  :     at com.XX.server.SunmiSystemServer.(SunmiSystemServer.java:55)02-26 20:00:47.055 27821 27821 I System  :     at com.android.server.SystemServer.startOtherServices(SystemServer.java:2414)02-26 20:00:47.055 27821 27821 I System  :     at com.android.server.SystemServer.run(SystemServer.java:944)02-26 20:00:47.055 27821 27821 I System  :     at com.android.server.SystemServer.main(SystemServer.java:654)02-26 20:00:47.055 27821 27821 I System  :     at java.lang.reflect.Method.invoke(Native Method)02-26 20:00:47.055 27821 27821 I System  :     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)02-26 20:00:47.055 27821 27821 I System  :     at com.android.internal.os.ZyGoteInit.main(ZygoteInit.java:920)02-26 20:00:47.055 27821 27821 W SystemServer: ***********************************************02-26 20:00:47.055 27821 27821 E SystemServer: BOOT FAILURE starting SunmiSystemServer02-26 20:00:47.055 27821 27821 E SystemServer: java.lang.IllegalArgumentException: android: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.02-26 20:00:47.055 27821 27821 E SystemServer: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.02-26 20:00:47.055 27821 27821 E SystemServer:     at android.app.PendingIntent.checkFlags(PendingIntent.java:404)02-26 20:00:47.055 27821 27821 E SystemServer:     at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:674)02-26 20:00:47.055 27821 27821 E SystemServer:     at android.app.PendingIntent.getBroadcast(PendingIntent.java:661)02-26 20:00:47.055 27821 27821 E SystemServer:     at com.XX.server.ntp.SunmiNetworkTimeUpdateService.(SunmiNetworkTimeUpdateService.java:148)02-26 20:00:47.055 27821 27821 E SystemServer:     at com.XX.server.SunmiSystemServer.(SunmiSystemServer.java:55)02-26 20:00:47.055 27821 27821 E SystemServer:     at com.android.server.SystemServer.startOtherServices(SystemServer.java:2414)02-26 20:00:47.055 27821 27821 E SystemServer:     at com.android.server.SystemServer.run(SystemServer.java:944)02-26 20:00:47.055 27821 27821 E SystemServer:     at com.android.server.SystemServer.main(SystemServer.java:654)02-26 20:00:47.055 27821 27821 E SystemServer:     at java.lang.reflect.Method.invoke(Native Method)02-26 20:00:47.055 27821 27821 E SystemServer:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)02-26 20:00:47.055 27821 27821 E SystemServer:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:920)02-26 20:00:47.056 27821 27821 D SystemServerTiming: StartPrintManager

修改方法:

   148         if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {   149             mPendingPollIntent = PendingIntent.getBroadcast(mContext, POLL_REQUEST, pollIntent, PendingIntent.FLAG_IMMUTABLE);   150         }else{   151             mPendingPollIntent = PendingIntent.getBroadcast(mContext, POLL_REQUEST, pollIntent, 0);   152         } 

参考:

App和SDK开发必看 | 个推分享Android12适配指南 - 知乎 (zhihu.com)

来源地址:https://blog.csdn.net/burly/article/details/129296597

--结束END--

本文标题: 【已解决】Android12以上PendingIntent需要强制增加FLAG_IMMUTABLE或FLAG_MUTABLE

本文链接: https://www.lsjlt.com/news/388192.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作