清泛IT社区

标题: 求助!关于拓展模块NotificationStyle的demo运行时报错的问题 [打印本页]

作者: Abi    时间: 前天 16:34
标题: 求助!关于拓展模块NotificationStyle的demo运行时报错的问题
我使用的是demo程序进行测试,拓展程序链接:
https://www.fun123.cn/reference/extensions/NotificationStyle.html

结果无论点什么按键都会报错:
edu.mit.appinventor.aicompanion3: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_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. if it needs to be used with inline replies or bubbles.
注意: 5秒钟后将报告另一条错误信息。



网上说是版本不兼容什么的,听说有原生的Notification模块,但我好像没找到





作者: App Inventor 2     时间: 前天 20:54
这个提示来自 Android 12(API 31)及以上版本的系统,对 PendingIntent 的使用进行了更严格的要求:
错误信息翻译如下:
edu.mit.appinventor.aicompanion3:目标 API 版本为 S+(即 API 31 及以上)时,创建 PendingIntent 时必须指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 其中之一。强烈建议使用 FLAG_IMMUTABLE,只有当某些功能确实依赖于可变性(如行内回复、通知气泡等)时才使用 FLAG_MUTABLE。
解决方法:
你需要检查源码中涉及 PendingIntent 的创建部分,添加适当的 flag。例如:
原来可能是这样写的:PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

修改为:PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);


-------------
正在修改,测试中,测试通过会发布我们自己的版本!







欢迎光临 清泛IT社区 (https://bbs.tsingfun.com/) Powered by Discuz! X3.3