More fragment work:
- Introduce FragmentManager as a public API, deprecating the fragment
APIs on Activity. (They will be removed soon.)
- Add APIs to write a fragment reference to a bundle and later retrieve
it.
- Add Fragment API to set another fragment as its target, for delivering
results.
- Change when onInflate() is called and formalize its meaning in relation
to the fragment arguments that were previously introduced.
- Change onDestroyView() to always be called, regardless of when
onCreateView() returns. It now also is called slightly differently,
after the view hierarchy's state is saved.
- Fix some issues with DialogFragment's lifecycle with its associated
Dialog and state save/restore.
- Preference can now have a Bundle associated with it to provide
arguments to a fragment. The data for this Bundle call be supplied
via <extra> tags under a PreferenceScreen.
- PreferenceActivity's header XML tags are now <preference-headers>
and <header>, and you can supply <extra> tags under a <header> to set
arguments for the header's fragment.
Change-Id: I22c212c9fa862d50840201ca16e51f9de5ef0031
diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java
index 117e507..ffc2862 100644
--- a/core/java/android/preference/Preference.java
+++ b/core/java/android/preference/Preference.java
@@ -90,6 +90,7 @@
private String mKey;
private Intent mIntent;
private String mFragment;
+ private Bundle mExtras;
private boolean mEnabled = true;
private boolean mSelectable = true;
private boolean mRequiresKey;
@@ -339,6 +340,26 @@
}
/**
+ * Return the extras Bundle object associated with this preference, creating
+ * a new Bundle if there currently isn't one. You can use this to get and
+ * set individual extra key/value pairs.
+ */
+ public Bundle getExtras() {
+ if (mExtras == null) {
+ mExtras = new Bundle();
+ }
+ return mExtras;
+ }
+
+ /**
+ * Return the extras Bundle object associated with this preference,
+ * returning null if there is not currently one.
+ */
+ public Bundle peekExtras() {
+ return mExtras;
+ }
+
+ /**
* Sets the layout resource that is inflated as the {@link View} to be shown
* for this Preference. In most cases, the default layout is sufficient for
* custom Preference objects and only the widget layout needs to be changed.