diff options
Diffstat (limited to 'core/java/android/appwidget/AppWidgetManager.java')
| -rw-r--r-- | core/java/android/appwidget/AppWidgetManager.java | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java index 077331e36f05..67c791df3c9a 100644 --- a/core/java/android/appwidget/AppWidgetManager.java +++ b/core/java/android/appwidget/AppWidgetManager.java @@ -417,6 +417,17 @@ public class AppWidgetManager { public static final String EXTRA_APPWIDGET_OLD_IDS = "appWidgetOldIds"; /** + * An extra that can be passed to + * {@link #requestPinAppWidget(ComponentName, Bundle, PendingIntent)}. This would allow the + * launcher app to present a custom preview to the user. + * + * <p> + * The value should be a {@link RemoteViews} similar to what is used with + * {@link #updateAppWidget} calls. + */ + public static final String EXTRA_APPWIDGET_PREVIEW = "appWidgetPreview"; + + /** * Field for the manifest meta-data tag. * * @see AppWidgetProviderInfo @@ -1073,7 +1084,7 @@ public class AppWidgetManager { /** * Return {@code TRUE} if the default launcher supports - * {@link #requestPinAppWidget(ComponentName, PendingIntent)} + * {@link #requestPinAppWidget(ComponentName, Bundle, PendingIntent)} */ public boolean isRequestPinAppWidgetSupported() { try { @@ -1084,6 +1095,15 @@ public class AppWidgetManager { } /** + * Only used during development. Can be deleted before release. + * @hide + */ + public boolean requestPinAppWidget(@NonNull ComponentName provider, + @Nullable PendingIntent successCallback) { + return requestPinAppWidget(provider, null, successCallback); + } + + /** * Request to pin an app widget on the current launcher. It's up to the launcher to accept this * request (optionally showing a user confirmation). If the request is accepted, the caller will * get a confirmation with extra {@link #EXTRA_APPWIDGET_ID}. @@ -1099,6 +1119,8 @@ public class AppWidgetManager { * * @param provider The {@link ComponentName} for the {@link * android.content.BroadcastReceiver BroadcastReceiver} provider for your AppWidget. + * @param extras In not null, this is passed to the launcher app. For eg {@link + * #EXTRA_APPWIDGET_PREVIEW} can be used for a custom preview. * @param successCallback If not null, this intent will be sent when the widget is created. * * @return {@code TRUE} if the launcher supports this feature. Note the API will return without @@ -1113,10 +1135,10 @@ public class AppWidgetManager { * service or when the user is locked. */ public boolean requestPinAppWidget(@NonNull ComponentName provider, - @Nullable PendingIntent successCallback) { + @Nullable Bundle extras, @Nullable PendingIntent successCallback) { try { - return mService.requestPinAppWidget(mPackageName, provider, - successCallback == null ? null : successCallback.getIntentSender()); + return mService.requestPinAppWidget(mPackageName, provider, extras, + successCallback == null ? null : successCallback.getIntentSender()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } |
