Skip to content

Commit 70d39c2

Browse files
Robert SchaubAndroid Git Automerger
authored andcommitted
am 2b85610: Merge "docs: Removed references to lockscreen widgets, added note to Android 5.0 changes page" into mnc-preview-docs
* commit '2b856100f67da1505eac30e2d989b84a2d68f20a': docs: Removed references to lockscreen widgets, added note to Android 5.0 changes page
2 parents 28006a3 + 2b85610 commit 70d39c2

2 files changed

Lines changed: 11 additions & 79 deletions

File tree

docs/html/about/versions/android-5.0-changes.jd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,3 +598,8 @@ android.provider.MediaStore#EXTRA_OUTPUT EXTRA_OUTPUT} should contain a content
598598
URI specifying where the photo should be stored. The camera app can write the
599599
image to the location specified by that URI, and the app that fired the intent
600600
would be able to read that file, even if the app is on the other profile. </p>
601+
602+
<h3>Lockscreen widget support removed</h3>
603+
604+
<p>Android 5.0 removes support for lockscreen widgets; it continues to support
605+
widgets on the home screen.</p>

docs/html/guide/topics/appwidgets/index.jd

Lines changed: 6 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ from
2626
</ol>
2727
</li>
2828
<li><a href="#preview">Setting a Preview Image</a></li>
29-
<li><a href="#lockscreen">Enabling App Widgets on the Lockscreen</a>
30-
<ol>
31-
<li><a href="#lockscreen-sizing">Sizing guidelines</a></li>
32-
</ol>
33-
</li>
34-
3529
<li><a href="#collections">Using App Widgets with Collections</a>
3630
<ol>
3731
<li><a href="#collection_sample">Sample application</a></li>
@@ -175,8 +169,7 @@ folder.</p>
175169
android:initialLayout="@layout/example_appwidget"
176170
android:configure="com.example.android.ExampleAppWidgetConfigure"
177171
android:resizeMode="horizontal|vertical"
178-
android:widgetCategory="home_screen|keyguard"
179-
android:initialKeyguardLayout="@layout/example_keyguard">
172+
android:widgetCategory="home_screen">
180173
&lt;/appwidget-provider>
181174
</pre>
182175

@@ -281,17 +274,11 @@ vertical resizing isn't enabled (see <code>resizeMode</code>). Introduced in And
281274
the widget can be resized. This field has no effect if it is greater than {@code minWidth} or if
282275
horizontal resizing isn't enabled (see <code>resizeMode</code>). Introduced in Android 4.0.</li>
283276

284-
<li>The <code>widgetCategory</code> attribute declares whether your App Widget can be displayed on the home screen,
285-
the lock screen (keyguard), or both. Values for this attribute include "home_screen" and "keyguard". A widget that
286-
is displayed on both needs to ensure that it follows the design guidelines for both widget classes. For more
287-
information, see <a href="#lockscreen">Enabling App Widgets on the Lockscreen</a>. The default value is "home_screen". Introduced in Android 4.2.
288-
</li>
289-
290-
<li>The <code>initialKeyguardLayout</code> attribute points to the layout resource
291-
that defines the lock screen App Widget layout. This works the same way as the
292-
{@link android.appwidget.AppWidgetProviderInfo#initialLayout android:initialLayout},
293-
in that it provides a layout that can appear immediately until your app widget is initialized and able to update
294-
the layout. Introduced in Android 4.2.</li>
277+
<li>The <code>widgetCategory</code> attribute declares whether your App Widget
278+
can be displayed on the home screen ({@code home_screen}), the lock screen
279+
({@code keyguard}), or both. Only Android versions lower than 5.0 support
280+
lock-screen widgets. For Android 5.0 and higher, only {@code home_screen} is
281+
valid.</li>
295282

296283
</ul>
297284

@@ -737,66 +724,6 @@ preview image, launch this application, select the app widget for your
737724
application and set it up how you'd like your preview image to appear, then save
738725
it and place it in your application's drawable resources.</p>
739726

740-
<h2 id="lockscreen">Enabling App Widgets on the Lockscreen</h2>
741-
742-
<p>Android 4.2 introduces the ability for users to add widgets to the lock screen. To indicate that your app widget is available for use on the lock screen, declare the {@link android.appwidget.AppWidgetProviderInfo#widgetCategory android:widgetCategory} attribute in the XML file that specifies your {@link android.appwidget.AppWidgetProviderInfo}. This attribute supports two values: "home_screen" and "keyguard". An app widget can declare support for one or both.</p>
743-
744-
<p>By default, every app widget supports placement on the Home screen, so "home_screen" is the default value for the
745-
{@link android.appwidget.AppWidgetProviderInfo#widgetCategory android:widgetCategory} attribute. If you want your app widget to be available for the lock screen, add the "keyguard" value:</p>
746-
<pre>
747-
&lt;appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
748-
...
749-
android:widgetCategory="keyguard|home_screen">
750-
&lt;/appwidget-provider>
751-
</pre>
752-
753-
<p>If you declare a widget to be displayable on both keyguard (lockscreen) and home, it's likely that you'll want to customize the widget depending on where it is displayed. For example, you might create a separate layout file for keyguard vs. home. The next step is to detect the widget category at runtime and respond accordingly.
754-
755-
You can detect whether your widget is on the lockscreen or home screen by calling
756-
{@link android.appwidget.AppWidgetManager#getAppWidgetOptions getAppWidgetOptions()}
757-
to get the widget's options as a {@link android.os.Bundle}. The returned bundle will include the key
758-
{@link android.appwidget.AppWidgetManager#OPTION_APPWIDGET_HOST_CATEGORY}, whose value will be one of {@link android.appwidget.AppWidgetProviderInfo#WIDGET_CATEGORY_HOME_SCREEN} or
759-
{@link android.appwidget.AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD}. This value is determined by the host into which the widget is bound. In the {@link android.appwidget.AppWidgetProvider}, you can then check the widget's category, for example:</p>
760-
761-
<pre>
762-
AppWidgetManager appWidgetManager;
763-
int widgetId;
764-
Bundle myOptions = appWidgetManager.getAppWidgetOptions (widgetId);
765-
766-
// Get the value of OPTION_APPWIDGET_HOST_CATEGORY
767-
int category = myOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
768-
769-
// If the value is WIDGET_CATEGORY_KEYGUARD, it's a lockscreen widget
770-
boolean isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
771-
</pre>
772-
773-
<p>Once you know the widget's category, you can optionally load a different base layout, set different properties, and so on. For example:</p>
774-
775-
<pre>
776-
int baseLayout = isKeyguard ? R.layout.keyguard_widget_layout : R.layout.widget_layout;
777-
</pre>
778-
779-
780-
<p>You should also specify an initial layout for your app widget when on the lock screen with the
781-
{@link android.appwidget.AppWidgetProviderInfo#initialKeyguardLayout android:initialKeyguardLayout} attribute. This works the same way as the
782-
{@link android.appwidget.AppWidgetProviderInfo#initialLayout android:initialLayout}, in that it provides a layout that can appear immediately until your app widget is initialized and able to update the layout.</p>
783-
784-
<h3 id="lockscreen-sizing">Sizing guidelines</h3>
785-
786-
<p>When a widget is hosted on the lockscreen, the framework ignores the {@code minWidth}, {@code minHeight}, {@code minResizeWidth}, and {@code minResizeHeight} fields. If a widget is also a home screen widget, these parameters are still needed as they're still used on home, but they will be ignored for purposes of the lockscreen.</p>
787-
788-
<p>The width of a lockscreen widget always fills the provided space. For the height of a lockscreen widget, you have the following options:</p>
789-
790-
<ul>
791-
<li>If the widget does not mark itself as vertically resizable ({@code android:resizeMode="vertical"}), then the widget height will always be "small":
792-
<ul>
793-
<li>On a phone in portrait mode, "small" is defined as the space remaining when an unlock UI is being displayed.</li>
794-
<li>On tablets and landscape phones, "small" is set on a per-device basis.</li>
795-
</ul>
796-
</li>
797-
<li>If the widget marks itself as vertically resizable, then the widget height shows up as "small" on portrait phones displaying an unlock UI. In all other cases, the widget sizes to fill the available height.</li>
798-
</ul>
799-
800727
<h2 id="collections">Using App Widgets with Collections</h2>
801728

802729
<p>Android 3.0 introduces app widgets with collections. These kinds of App

0 commit comments

Comments
 (0)