Intent.putExtras size limit?

后端 未结 3 1926
执念已碎
执念已碎 2020-12-02 01:57

I\'m trying to pass data from one activity to another via Intent.putExtras like this:

private ArrayList         


        
3条回答
  •  长情又很酷
    2020-12-02 02:51

    Maximum size is 1MB at Process Level, not at bundle level. This 1MB is for a shared buffer used by all state transactions in progress in the app's process, e.g. onSaveInstanceState, startActivity and others.

    On Android 7.0 (API level 24) and higher, the system throws a TransactionTooLargeException when this process level limit is reached. On older versions you only get a warning.

    So others suggested, you should research alternatives, if you need to pass a larger payload, e.g. use local database, file system, application level in-memory cache, remote storage, shared preferences (although these need to be small too), etc.

    Source of truth: https://developer.android.com/guide/components/activities/parcelables-and-bundles

提交回复
热议问题