Android 14 标志可变

问题描述 投票:0回答:1

我正在努力在某个应用程序中支持 android 14,我遇到了 android 本机共享表的一个问题,因为我们对 FLAG_MUTABLE 有一个未决的意图,我收到此错误

2023-10-16 14:23:20.368 10001-10001        com.package.x.android.shopping    E  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.package.x.android.shop/com.package.x.NativeShareActivity}: java.lang.IllegalArgumentException: com.package.x.android.shop: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.

基于android 14文档,出于安全原因,不可能再使用flag_mutableendingIntent,并且将pending意图更改为FLAG_IMMUTABLE将阻止我们获取客户选择的共享通道,有没有办法使用flag*_immutable和仍然可以得到客户选择的分享渠道。

我尝试将意图类型更改为显式,但是我不确定在这种情况下组件名称应该是什么。

谢谢。

immutability android-pendingintent android-14 android-sharesheet
1个回答
0
投票

错误消息中给出了组件名称:

com.package.x.android.shop/com.package.x.NativeShareActivity

要使

Intent
明确,您只需将包名称设置为
com.package.x.android.shop
即可。

© www.soinside.com 2019 - 2024. All rights reserved.