startActivityForResult时出现TransactionTooLargeException

时间:2019-05-17 18:15:42

标签: android

我有一个Android应用程序,该应用程序在具有1GB RAM的设备中出现故障。

使用startActivityForResult打开活动时,我收到TransactionTooLargeException。如果将它们更改为startActivity可以,但是我需要这些活动的结果。

我遵循以下建议,但对我而言无效:

@Override
    protected void onSaveInstanceState(Bundle oldInstanceState) {
        super.onSaveInstanceState(oldInstanceState);
        oldInstanceState.clear();
    }

一个重要的评论是,我没有从后端获取任何信息,因此它不是导致此问题的大json文件。

意图也很简单:

intent = new Intent(getActivity(), OtherPaymentAddActivity.class);
                intent.putExtra("isAdd", true);
                startActivityForResult(intent, Constants.OTHER_PAYMENT_ADDED);
                break;

有办法避免这个问题吗?

这里有LogCat

    Event recorded: Event{appId='com.payment.collection', name='screen_view(_vs)', params=Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=MainFragmentManager, firebase_previous_id(_pi)=-1269867677418891571, firebase_screen_class(_sc)=CheckAddActivity, firebase_screen_id(_si)=-1269867677418891570}]}
05-28 13:20:57.631 2291-3874/com.google.android.gms V/FA: Upload scheduled in approximately ms: 3362813
    Cancelling job. JobID: 812057698
05-28 13:20:57.632 2291-3874/com.google.android.gms V/FA: Scheduling upload with GcmTaskService
    Scheduling task with Gcm. time: 3362813
05-28 13:20:57.635 2291-3874/com.google.android.gms V/FA: Background event processing time, ms: 8
05-28 13:20:58.004 3564-3564/com.payment.collection E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 523184)
05-28 13:20:58.004 3564-3564/com.payment.collection D/AndroidRuntime: Shutting down VM


    --------- beginning of crash
05-28 13:20:58.007 3564-3564/com.payment.collection E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.payment.collection, PID: 3564
    java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 523184 bytes
        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3752)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
     Caused by: android.os.TransactionTooLargeException: data parcel size 523184 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(Binder.java:615)
        at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3606)
        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3744)
        at android.os.Handler.handleCallback(Handler.java:751) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6077) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 
05-28 13:20:58.011 1615-1863/system_process W/ActivityManager:   Force finishing activity com.payment.collection/.MainActivities.CheckAddActivity
05-28 13:20:58.055 1615-1683/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
05-28 13:20:58.055 1615-1683/system_process D/OpenGLRenderer: Swap behavior 1
05-28 13:20:58.056 1615-1683/system_process W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVE

1 个答案:

答案 0 :(得分:0)

最后,是我将Bundle中的可序列化项目列表发送给Fragment,其中包含3K项目,它不是复杂的项目,只是具有某些属性的对象...

因此,我重新调整了逻辑以避免这样做。作为一个教训,请注意您输入的内容:

Bundle bundle = new Bundle();
bundle.putSerializable("list", itemList);