安卓TransactionTooLargeException当调TakePicture

0

的问题

需要运用摄像机我的应用程序的工作,我看这事情已经改变API>=28个相比,我是如何用来做这里,我可以使用startActivityForResult.

但是我面临的一个问题,我启动相机应用程序,并立即得到'TransactionTooLargeException'错误消息,在调试和运行控制台。

调用了照相机,我做的

mGetContent = registerForActivityResult(
            new ActivityResultContracts.TakePicture(),
            result -> {
                if (result) {

                }
            }
    );

在mGetContent是在该类中定义为

private ActivityResultLauncher<Uri> mGetContent;

我AndroidManifest.xml 文件我已经下

<provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="com.test.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
    </provider>

在我file_paths文件,我有

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path
        name="files"
        path="."/>
    <files-path
        name="app_images"
        path="./files/"/>
</paths>

我有一个按钮设置在我的活动,我启动摄像机的使用

findViewById(R.id.button)).setOnClickListener(v -> {
    File directory = new File(context.getFilesDir(), "app_images");
    if (!directory.exists()) directory.mkdir();

    File file = new File(directory, "image.jpg");

    Uri uri = getUriForFile(this, "com.test.fileprovider", file);

    mGetContent.launch(uri);
};

当我敲击按钮时,和摄影机应用程序开辟了,我得到什么,我只能假设是一个过于一般性的错误信息。

E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 1284092)
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.test, PID: 14296
    java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1284092 bytes
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:161)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7397)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
     Caused by: android.os.TransactionTooLargeException: data parcel size 1284092 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(BinderProxy.java:511)
        at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4524)
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)

直试图谷歌搜索找到的东西,但是有麻烦钉下什么样的实际问题。

一些建议指出我对onSaveInstanceState,所以我复盖,并设置一个断点上来看看发生了什么事,但它提出了它的通过没有任何问题(从什么我可以告诉).

种损失的这一个。

android android-camera java
2021-11-24 06:48:37
1

最好的答案

0

Wowsers为什么捆绑在onSaveInstanceState.

我有一些imageviews,imagebuttons,只是一般的按钮在我的应用程序,使事情更容易对我们的工作人员。

我去通过和改变的'saveState'的所有ImageViews和ImageButtons从默认真的假的,因为我不关心什么状态,他们只是些指南。

把机器人:viewHierarchyState从1.2MB下降到1.6KB,我的包裹尺寸是现在3.3KB,它不再崩溃时暂停应用程序来把摄像机应用程序。

TooLargeTool是有用的,但我不能让它工作的方式。页说,我告诉了'startLogging',并且在我的活动,在那里崩溃发生的事情,我设置一个断点和检查,如果这是日志使用'isLogging'和它回来了'true'。

在结束我刚记录输出 TooLargeTool.bundleBreakdown(outState) 在onSaveInstanceState.

感谢加布Sechan和ianhanniballake指着我对什么它可能是,没有多少有关于这个特定的例外,我的意思是,没有,但是看来,它是每个人都不同。

真希望谷歌会打印出来的一套更好的错误信息,使它更容易作出哪些活动是问题所在(或在我的情况下,所有3项活动合并).

2021-11-25 05:48:50

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................