5151 * an exhibition/lean-back experience.</p>
5252 *
5353 * <p>The Dream lifecycle is as follows:</p>
54- * <ul>
55- * <li>onAttachedToWindow</li>
56- * <li>onDreamingStarted</li>
57- * <li>onDreamingStopped</li>
58- * <li>onDetachedFromWindow</li>
59- * </ul>
54+ * <ol>
55+ * <li>{@link #onAttachedToWindow}
56+ * <p>Use this for initial setup, such as calling {@link #setContentView setContentView()}.</li>
57+ * <li>{@link #onDreamingStarted}
58+ * <p>Your dream has started, so you should begin animations or other behaviors here.</li>
59+ * <li>{@link #onDreamingStopped}
60+ * <p>Use this to stop the things you started in {@link #onDreamingStarted}.</li>
61+ * <li>{@link #onDetachedFromWindow}
62+ * <p>Use this to dismantle resources your dream set up. For example, detach from handlers
63+ * and listeners.</li>
64+ * </ol>
6065 *
6166 * <p>In addition, onCreate and onDestroy (from the Service interface) will also be called, but
6267 * initialization and teardown should be done by overriding the hooks above.</p>
8085 * android:resource="@xml/my_dream" />
8186 * </service>
8287 * </pre>
83- * <p>If specified, additional information for the dream is defined using the
84- * <code><{@link android.R.styleable#Dream dream}></code> element. For example:</p>
85- * <pre>
86- * (in res/xml/my_dream.xml)
8788 *
89+ * <p>If specified with the {@code <meta-data>} element,
90+ * additional information for the dream is defined using the
91+ * {@link android.R.styleable#Dream <dream>} element in a separate XML file.
92+ * Currently, the only addtional
93+ * information you can provide is for a settings activity that allows the user to configure
94+ * the dream behavior. For example:</p>
95+ * <p class="code-caption">res/xml/my_dream.xml</p>
96+ * <pre>
8897 * <dream xmlns:android="http://schemas.android.com/apk/res/android"
8998 * android:settingsActivity="com.example.app/.MyDreamSettingsActivity" />
9099 * </pre>
100+ * <p>This makes a Settings button available alongside your dream's listing in the
101+ * system settings, which when pressed opens the specified activity.</p>
102+ *
103+ *
104+ * <p>To specify your dream layout, call {@link #setContentView}, typically during the
105+ * {@link #onAttachedToWindow} callback. For example:</p>
106+ * <pre>
107+ * public class MyDream extends DreamService {
108+ *
109+ * @Override
110+ * public void onAttachedToWindow() {
111+ * super.onAttachedToWindow();
112+ *
113+ * // Exit dream upon user touch
114+ * setInteractive(false);
115+ * // Hide system UI
116+ * setFullscreen(true);
117+ * // Set the dream layout
118+ * setContentView(R.layout.dream);
119+ * }
120+ * }
121+ * </pre>
91122 */
92123public class DreamService extends Service implements Window .Callback {
93124 private final String TAG = DreamService .class .getSimpleName () + "[" + getClass ().getSimpleName () + "]" ;
@@ -323,11 +354,12 @@ public void setContentView(int layoutResID) {
323354
324355 /**
325356 * Sets a view to be the content view for this Dream.
326- * Behaves similarly to {@link android.app.Activity#setContentView(android.view.View)},
357+ * Behaves similarly to {@link android.app.Activity#setContentView(android.view.View)} in an activity ,
327358 * including using {@link ViewGroup.LayoutParams#MATCH_PARENT} as the layout height and width of the view.
328359 *
329- * <p>Note: Requires a window, do not call before {@link #onAttachedToWindow()}</p>
330- * @param view The desired content to display.
360+ * <p>Note: This requires a window, so you should usually call it during
361+ * {@link #onAttachedToWindow()} and never earlier (you <strong>cannot</strong> call it
362+ * during {@link #onCreate}).</p>
331363 *
332364 * @see #setContentView(int)
333365 * @see #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
@@ -339,9 +371,12 @@ public void setContentView(View view) {
339371 /**
340372 * Sets a view to be the content view for this Dream.
341373 * Behaves similarly to
342- * {@link android.app.Activity#setContentView(android.view.View, android.view.ViewGroup.LayoutParams)}.
374+ * {@link android.app.Activity#setContentView(android.view.View, android.view.ViewGroup.LayoutParams)}
375+ * in an activity.
343376 *
344- * <p>Note: Requires a window, do not call before {@link #onAttachedToWindow()}</p>
377+ * <p>Note: This requires a window, so you should usually call it during
378+ * {@link #onAttachedToWindow()} and never earlier (you <strong>cannot</strong> call it
379+ * during {@link #onCreate}).</p>
345380 *
346381 * @param view The desired content to display.
347382 * @param params Layout parameters for the view.
0 commit comments