diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-03-19 20:51:09 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-03-19 20:51:09 +0000 |
commit | d1f823df788ae3cc08fc7808a803e76f7a5a070c (patch) | |
tree | f268eba19dccdbf67ad77e70965eec09d1dc3ce6 | |
parent | 444ff8b1702da95ce180bb1ddc5a8e2abe1493c4 (diff) | |
parent | 6bfdace305d33f286b97b26a942aee909292ce25 (diff) | |
download | docs-d1f823df788ae3cc08fc7808a803e76f7a5a070c.tar.gz |
Merge "Clarify Bundle recommendation" into main
-rw-r--r-- | api-guidelines/framework.md | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/api-guidelines/framework.md b/api-guidelines/framework.md index 85b67ce..5464a53 100644 --- a/api-guidelines/framework.md +++ b/api-guidelines/framework.md @@ -10,8 +10,16 @@ Creators for intents should use methods named `createFooIntent()`. ### Use `Bundle`s instead of creating new general-purpose data structures <a name="framework-bundle"></a> -Instead of creating a new type/class to hold various args or various types, -consider simply using a `Bundle` instead. +Avoid creating new general-purpose data structures to represent arbitrary key to +typed value mappings. Instead, consider using `Bundle`. + +This typically comes up when writing platform APIs that serve as communication +channels between non-platform apps and services, where the platform does not +read the data sent across the channel and the API contract may be partially +defined outside of the platform (ex. in a Jetpack library). + +In cases where the platform *does* read the data, avoid using `Bundle` and +prefer a strongly-typed data class. ### Parcelable implementations must have public `CREATOR` field <a name="framework-parcelable-creator"></a> |