android - TransactionTooLargeException when selecting many files using ACTION_GET_CONTENT intent
问题描述
If you open an FileChooser using Intent.ACTION_GET_CONTENT
and select a huge amount of files e.g. 2500, a TransactionTooLargeException
will be thrown and then the process is killed without resuming in onActivityResult
:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(CATEGORY_OPENABLE);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent = Intent.createChooser(intent, "Foo");
startActivityForResult(intent, 121);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// logic stuff
}
}
How is it possible to let the user decide how many files to select without destroying the app?
解决方案
除了跳过之外,您没有办法限制用户做出的选择次数EXTRA_ALLOW_MULTIPLE
。
由ACTION_GET_CONTENT
实现(Android、设备制造商或应用程序开发人员)将选择的数量限制在不太可能导致问题的某个数量。显然,在您的设备上和这种情况下,ACTION_GET_CONTENT
实现存在错误。如果您确定它是谁,请考虑提交错误报告。
推荐阅读
- ios - 如何为重用准备约束?
- r - 更改函数 `lubridate::yday` 的开始日期
- linux - 创建一个宏将存储在rax中的数字打印到控制台,宏也应该有错误处理
- hibernate - 如何使用 Spring Data Jpa 动态更改模式名称?
- r - 在 R 中使用凌乱的调查数据进行分组并扩大范围
- google-colaboratory - 尝试在 colab 中将 zip 文件从驱动器下载到实例达到配额限制
- javascript - 如何让 createSlice() 更新我的页面?
- c - 如何从stat中获取文件路径
- r - Sum Dice 样本结果并将它们放入表中
- c# - Entity Framework Core 在导航属性上调用表达式