【发布时间】:2018-02-07 10:33:18
【问题描述】:
当我打开图库并选择图像应用程序时出现崩溃 "java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 539544 bytes" 异常
代码如下
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, SELECT_PHOTO_FROM_GALLERY);
和在活动结果方法中
openDialog.dismiss();
try {
if (data == null || data.getData() == null) {
Toast.makeText(getContext(), "Error getting image.", Toast.LENGTH_SHORT).show();
return;
}
mUri = data.getData();
createFile(mUri, null);
} catch (Exception e) {
Log.e(TAG, "GALLERY EXCEPTION " + e.toString());
} catch (OutOfMemoryError E) {
Log.e(TAG, "GALLERY MEMORY EXCEPTION " + E.toString());
}
我没有使用onSavedInstancestate()。和
我已经推荐了
What to do on TransactionTooLargeException
和
http://nemanjakovacevic.net/blog/english/2015/03/24/yet-another-post-on-serializable-vs-parcelable/
【问题讨论】:
-
openDialog.dismiss();????那应该怎么做? -
createFile(mUri, null);` 你不认为这个函数会导致异常吗?所以发布代码。
-
When I open gallery and select a image app get crash with the exception不信你。只有在 onActivityResult 中做某事,你才会得到那个例外。