What to do on TransactionTooLargeException

前端 未结 30 3951
盖世英雄少女心
盖世英雄少女心 2020-11-22 03:08

I got a TransactionTooLargeException. Not reproducible. In the docs it says

The Binder transaction failed because it was too large.

D

30条回答
  •  天命终不由人
    2020-11-22 03:47

    Try to use EventBus or ContentProvider like solution.

    If you are in the same process(normally all your activities would be), try to use EventBus, cause in process data exchange does NOT need a somewhat buffer, so you do not need to worry about your data is too large. (You can just use method call to pass data indeed, and EventBus hide the ugly things) Here is the detail:

    // one side
    startActivity(intentNotTooLarge);
    EventBus.getDefault().post(new FooEvent(theHugeData));
    
    // the other side
    @Subscribe public void handleData(FooEvent event) { /* get and handle data */ }
    

    If the two sides of Intent are not in the same process, try somewhat ContentProvider.


    See TransactionTooLargeException

    The Binder transaction failed because it was too large.

    During a remote procedure call, the arguments and the return value of the call are transferred as Parcel objects stored in the Binder transaction buffer. If the arguments or the return value are too large to fit in the transaction buffer, then the call will fail and TransactionTooLargeException will be thrown.

提交回复
热议问题