summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralanv <alanv@google.com>2024-03-19 13:48:09 -0700
committerAndroid API Council <copybara-worker@google.com>2024-03-19 13:48:53 -0700
commit6bfdace305d33f286b97b26a942aee909292ce25 (patch)
treef268eba19dccdbf67ad77e70965eec09d1dc3ce6
parent444ff8b1702da95ce180bb1ddc5a8e2abe1493c4 (diff)
downloaddocs-6bfdace305d33f286b97b26a942aee909292ce25.tar.gz
Clarify Bundle recommendation
Follow-up from API Council Leads meeting. PiperOrigin-RevId: 617282551 Change-Id: If169b642451478f6c21ba5c087565764bf584251
-rw-r--r--api-guidelines/framework.md12
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>