You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android 13下Intent传递IntegerArrayList返回null问题及解决

Android 13下Intent传递IntegerArrayList返回null的问题与解决

自Android 13起,通过Intent传递数据需配置Intent Filter和Categories。我尝试使用Intent.PutIntegerArrayListExtra方法传递数据,配置了如下Intent Filter,但未生效,推测需要指定DataMimeType,但不清楚ArrayList对应的类型。

[IntentFilter(new[] { Intent.ActionSend }, Categories = new[] {
    Intent.CategoryDefault })
]

更新:问题详情

第一个Activity代码:

var intent = new Intent(this, typeof(ExampleActivity));
intent.PutIntegerArrayListExtra("Items", items.Select(x => (Java.Lang.Integer)x).ToList());

第二个Activity代码:

var items= Intent.GetStringArrayListExtra("Items");

在Android 13上,上述代码获取到的items为null。

解决方案

第一个Activity修改后的代码:

Bundle bundle = new Bundle();
var intent = new Intent(this, typeof(ExampleActivity));
List<Java.Lang.Integer> itemsArrayList = items.Select(x => (Java.Lang.Integer)x).ToList();
bundle.PutIntegerArrayList("Items", itemsArrayList);
intent.PutExtras(bundle);

第二个Activity修改后的代码:

Bundle bundle = Intent.Extras;
var items = bundle.GetIntegerArrayList("Items");

内容的提问来源于stack exchange,提问作者Ahmet Onay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 13:40:40