Skip to content

Commit 70b43e4

Browse files
scottamainAndroid Git Automerger
authored andcommitted
am f1d4dc3: am db24231: Merge "docs: add Settings dev guide; a few changes to javadocs" into jb-dev
* commit 'f1d4dc3844510eb02cffd49c81ce2ec297758a6f': docs: add Settings dev guide; a few changes to javadocs
2 parents 0c8a776 + f1d4dc3 commit 70b43e4

File tree

9 files changed

+1208
-8
lines changed

9 files changed

+1208
-8
lines changed

core/java/android/preference/PreferenceManager.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,19 +415,20 @@ public Preference findPreference(CharSequence key) {
415415
}
416416

417417
/**
418-
* Sets the default values from a preference hierarchy in XML. This should
418+
* Sets the default values from an XML preference file by reading the values defined
419+
* by each {@link Preference} item's {@code android:defaultValue} attribute. This should
419420
* be called by the application's main activity.
420421
* <p>
421-
* If {@code readAgain} is false, this will only set the default values if this
422-
* method has never been called in the past (or the
423-
* {@link #KEY_HAS_SET_DEFAULT_VALUES} in the default value shared
424-
* preferences file is false). To attempt to set the default values again
425-
* bypassing this check, set {@code readAgain} to true.
426422
*
427423
* @param context The context of the shared preferences.
428-
* @param resId The resource ID of the preference hierarchy XML file.
424+
* @param resId The resource ID of the preference XML file.
429425
* @param readAgain Whether to re-read the default values.
430-
* <p>
426+
* If false, this method sets the default values only if this
427+
* method has never been called in the past (or if the
428+
* {@link #KEY_HAS_SET_DEFAULT_VALUES} in the default value shared
429+
* preferences file is false). To attempt to set the default values again
430+
* bypassing this check, set {@code readAgain} to true.
431+
* <p class="note">
431432
* Note: this will NOT reset preferences back to their default
432433
* values. For that functionality, use
433434
* {@link PreferenceManager#getDefaultSharedPreferences(Context)}
@@ -445,6 +446,25 @@ public static void setDefaultValues(Context context, int resId, boolean readAgai
445446
* Similar to {@link #setDefaultValues(Context, int, boolean)} but allows
446447
* the client to provide the filename and mode of the shared preferences
447448
* file.
449+
*
450+
* @param context The context of the shared preferences.
451+
* @param sharedPreferencesName A custom name for the shared preferences file.
452+
* @param sharedPreferencesMode The file creation mode for the shared preferences file, such
453+
* as {@link android.content.Context#MODE_PRIVATE} or {@link
454+
* android.content.Context#MODE_PRIVATE}
455+
* @param resId The resource ID of the preference XML file.
456+
* @param readAgain Whether to re-read the default values.
457+
* If false, this method will set the default values only if this
458+
* method has never been called in the past (or if the
459+
* {@link #KEY_HAS_SET_DEFAULT_VALUES} in the default value shared
460+
* preferences file is false). To attempt to set the default values again
461+
* bypassing this check, set {@code readAgain} to true.
462+
* <p class="note">
463+
* Note: this will NOT reset preferences back to their default
464+
* values. For that functionality, use
465+
* {@link PreferenceManager#getDefaultSharedPreferences(Context)}
466+
* and clear it followed by a call to this method with this
467+
* parameter set to true.
448468
*
449469
* @see #setDefaultValues(Context, int, boolean)
450470
* @see #setSharedPreferencesName(String)

docs/html/guide/components/fragments.jd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,12 @@ href="{@docRoot}guide/components/activities.html#Lifecycle">managing the activit
709709
lifecycle</a> also apply to fragments. What you also need to understand, though, is how the life
710710
of the activity affects the life of the fragment.</p>
711711

712+
<p class="caution"><strong>Caution:</strong> If you need a {@link android.content.Context} object
713+
within your {@link android.app.Fragment}, you can call {@link android.app.Fragment#getActivity()}.
714+
However, be careful to call {@link android.app.Fragment#getActivity()} only when the fragment is
715+
attached to an activity. When the fragment is not yet attached, or was detached during the end of
716+
its lifecycle, {@link android.app.Fragment#getActivity()} will return null.</p>
717+
712718

713719
<h3 id="CoordinatingWithActivity">Coordinating with the activity lifecycle</h3>
714720

docs/html/guide/guide_toc.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ localized titles are added in the language order specified below.
197197
<li><a href="<?cs var:toroot ?>guide/topics/ui/actionbar.html">
198198
<span class="en">Action Bar</span>
199199
</a></li>
200+
<li><a href="<?cs var:toroot ?>guide/topics/ui/settings.html">
201+
<span class="en">Settings</span>
202+
</a></li>
200203
<li class="nav-section">
201204
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/index.html">
202205
<span class="en">Notifications</span>

0 commit comments

Comments
 (0)