public class AppWidgetManager extends Object
For more information about creating app widgets, read the App Widgets developer guide.
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_APPWIDGET_BIND
Activity action to launch from your
AppWidgetHost activity when you want to bind
an AppWidget to display and bindAppWidgetIdIfAllowed returns false. |
static String |
ACTION_APPWIDGET_CONFIGURE
Sent when it is time to configure your AppWidget while it is being added to a host.
|
static String |
ACTION_APPWIDGET_DELETED
Sent when an instance of an AppWidget is deleted from its host.
|
static String |
ACTION_APPWIDGET_DISABLED
Sent when the last AppWidget of this provider is removed from the last host.
|
static String |
ACTION_APPWIDGET_ENABLED
Sent when an instance of an AppWidget is added to a host for the first time.
|
static String |
ACTION_APPWIDGET_HOST_RESTORED
Sent to widget hosts after AppWidget state related to the host has been restored from
backup.
|
static String |
ACTION_APPWIDGET_OPTIONS_CHANGED
Sent when the custom extras for an AppWidget change.
|
static String |
ACTION_APPWIDGET_PICK
Activity action to launch from your
AppWidgetHost activity when you want to
pick an AppWidget to display. |
static String |
ACTION_APPWIDGET_RESTORED
Sent to an
AppWidgetProvider after AppWidget state related to that provider has
been restored from backup. |
static String |
ACTION_APPWIDGET_UPDATE
Sent when it is time to update your AppWidget.
|
static String |
ACTION_KEYGUARD_APPWIDGET_PICK
Similar to ACTION_APPWIDGET_PICK, but used from keyguard
|
static String |
EXTRA_APPWIDGET_ID
An intent extra that contains one appWidgetId.
|
static String |
EXTRA_APPWIDGET_IDS
An intent extra that contains multiple appWidgetIds.
|
static String |
EXTRA_APPWIDGET_OLD_IDS
An intent extra that contains multiple appWidgetIds.
|
static String |
EXTRA_APPWIDGET_OPTIONS
An intent extra which points to a bundle of extra information for a particular widget id.
|
static String |
EXTRA_APPWIDGET_PROVIDER
An intent extra that contains the component name of a AppWidget provider.
|
static String |
EXTRA_APPWIDGET_PROVIDER_PROFILE
An intent extra that contains the user handle of the profile under
which an AppWidget provider is registered.
|
static String |
EXTRA_CATEGORY_FILTER
An intent extra to pass to the AppWidget picker which allows the picker to filter
the list based on the
AppWidgetProviderInfo.widgetCategory . |
static String |
EXTRA_CUSTOM_EXTRAS
|
static String |
EXTRA_CUSTOM_INFO
An intent extra to pass to the AppWidget picker containing a
List of
AppWidgetProviderInfo objects to mix in to the list of AppWidgets that are
installed. |
static String |
EXTRA_CUSTOM_SORT
An intent extra to pass to the AppWidget picker to specify whether or not to sort
the list of caller-specified extra AppWidgets along with the rest of the AppWidgets
|
static String |
EXTRA_HOST_ID
An intent extra attached to the
ACTION_APPWIDGET_HOST_RESTORED broadcast,
indicating the integer ID of the host whose widgets have just been restored. |
static int |
INVALID_APPWIDGET_ID
A sentinel value that the AppWidget manager will never return as a appWidgetId.
|
static String |
META_DATA_APPWIDGET_PROVIDER
Field for the manifest meta-data tag.
|
static String |
OPTION_APPWIDGET_HOST_CATEGORY
A bundle extra that hints to the AppWidgetProvider the category of host that owns this
this widget.
|
static String |
OPTION_APPWIDGET_MAX_HEIGHT
A bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
|
static String |
OPTION_APPWIDGET_MAX_WIDTH
A bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
|
static String |
OPTION_APPWIDGET_MIN_HEIGHT
A bundle extra that contains the lower bound on the current height, in dips, of a widget instance.
|
static String |
OPTION_APPWIDGET_MIN_WIDTH
A bundle extra that contains the lower bound on the current width, in dips, of a widget instance.
|
Constructor and Description |
---|
AppWidgetManager(Context context,
IAppWidgetService service)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
bindAppWidgetId(int appWidgetId,
ComponentName provider)
Set the component for a given appWidgetId.
|
void |
bindAppWidgetId(int appWidgetId,
ComponentName provider,
Bundle options)
Set the component for a given appWidgetId.
|
boolean |
bindAppWidgetIdIfAllowed(int appWidgetId,
ComponentName provider)
Set the component for a given appWidgetId.
|
boolean |
bindAppWidgetIdIfAllowed(int appWidgetId,
ComponentName provider,
Bundle options)
Set the component for a given appWidgetId.
|
boolean |
bindAppWidgetIdIfAllowed(int appWidgetId,
UserHandle user,
ComponentName provider,
Bundle options)
Set the provider for a given appWidgetId if the caller has a permission.
|
void |
bindRemoteViewsService(String packageName,
int appWidgetId,
Intent intent,
IBinder connection)
Binds the RemoteViewsService for a given appWidgetId and intent.
|
int[] |
getAppWidgetIds(ComponentName provider)
Get the list of appWidgetIds that have been bound to the given AppWidget
provider.
|
AppWidgetProviderInfo |
getAppWidgetInfo(int appWidgetId)
Get the available info about the AppWidget.
|
Bundle |
getAppWidgetOptions(int appWidgetId)
Get the extras associated with a given widget instance.
|
List<AppWidgetProviderInfo> |
getInstalledProviders()
Return a list of the AppWidget providers that are currently installed.
|
List<AppWidgetProviderInfo> |
getInstalledProviders(int categoryFilter)
Gets the AppWidget providers for the current user.
|
List<AppWidgetProviderInfo> |
getInstalledProvidersForProfile(int categoryFilter,
UserHandle profile)
Gets the AppWidget providers for the given user profile.
|
List<AppWidgetProviderInfo> |
getInstalledProvidersForProfile(UserHandle profile)
Gets the AppWidget providers for the given user profile.
|
static AppWidgetManager |
getInstance(Context context)
Get the AppWidgetManager instance to use for the supplied
Context object. |
boolean |
hasBindAppWidgetPermission(String packageName)
Query if a given package was granted permission by the user to bind app widgets
You need the MODIFY_APPWIDGET_BIND_PERMISSIONS permission |
boolean |
hasBindAppWidgetPermission(String packageName,
int userId)
Query if a given package was granted permission by the user to bind app widgets
You need the MODIFY_APPWIDGET_BIND_PERMISSIONS permission |
boolean |
isBoundWidgetPackage(String packageName,
int userId) |
void |
notifyAppWidgetViewDataChanged(int[] appWidgetIds,
int viewId)
Notifies the specified collection view in all the specified AppWidget instances
to invalidate their data.
|
void |
notifyAppWidgetViewDataChanged(int appWidgetId,
int viewId)
Notifies the specified collection view in the specified AppWidget instance
to invalidate its data.
|
void |
partiallyUpdateAppWidget(int[] appWidgetIds,
RemoteViews views)
Perform an incremental update or command on the widget(s) specified by appWidgetIds.
|
void |
partiallyUpdateAppWidget(int appWidgetId,
RemoteViews views)
Perform an incremental update or command on the widget specified by appWidgetId.
|
void |
setBindAppWidgetPermission(String packageName,
boolean permission)
Changes any user-granted permission for the given package to bind app widgets
You need the MODIFY_APPWIDGET_BIND_PERMISSIONS permission |
void |
setBindAppWidgetPermission(String packageName,
int userId,
boolean permission)
Changes any user-granted permission for the given package to bind app widgets
You need the MODIFY_APPWIDGET_BIND_PERMISSIONS permission |
void |
unbindRemoteViewsService(String packageName,
int appWidgetId,
Intent intent)
Unbinds the RemoteViewsService for a given appWidgetId and intent.
|
void |
updateAppWidget(ComponentName provider,
RemoteViews views)
Set the RemoteViews to use for all AppWidget instances for the supplied AppWidget provider.
|
void |
updateAppWidget(int[] appWidgetIds,
RemoteViews views)
Set the RemoteViews to use for the specified appWidgetIds.
|
void |
updateAppWidget(int appWidgetId,
RemoteViews views)
Set the RemoteViews to use for the specified appWidgetId.
|
void |
updateAppWidgetOptions(int appWidgetId,
Bundle options)
Update the extras for a given widget instance.
|
public static final String ACTION_APPWIDGET_PICK
AppWidgetHost
activity when you want to
pick an AppWidget to display. The AppWidget picker activity will be launched.
You must supply the following extras:
EXTRA_APPWIDGET_ID |
A newly allocated appWidgetId, which will be bound to the AppWidget provider once the user has selected one. |
The system will respond with an onActivityResult call with the following extras in the intent:
EXTRA_APPWIDGET_ID |
The appWidgetId that you supplied in the original intent. |
When you receive the result from the AppWidget pick activity, if the resultCode is
Activity.RESULT_OK
, an AppWidget has been selected. You should then
check the AppWidgetProviderInfo for the returned AppWidget, and if it has one, launch its
configuration activity. If Activity.RESULT_CANCELED
is returned, you
should delete the appWidgetId.
ACTION_APPWIDGET_CONFIGURE
,
Constant Field Valuespublic static final String ACTION_KEYGUARD_APPWIDGET_PICK
public static final String ACTION_APPWIDGET_BIND
AppWidgetHost
activity when you want to bind
an AppWidget to display and bindAppWidgetIdIfAllowed returns false.
You must supply the following extras:
EXTRA_APPWIDGET_ID |
A newly allocated appWidgetId, which will be bound to the AppWidget provider you provide. |
EXTRA_APPWIDGET_PROVIDER |
The BroadcastReceiver that will be the AppWidget provider for this AppWidget. |
EXTRA_APPWIDGET_PROVIDER_PROFILE |
An optional handle to a user profile under which runs the provider for this AppWidget. |
The system will respond with an onActivityResult call with the following extras in the intent:
EXTRA_APPWIDGET_ID |
The appWidgetId that you supplied in the original intent. |
When you receive the result from the AppWidget bind activity, if the resultCode is
Activity.RESULT_OK
, the AppWidget has been bound. You should then
check the AppWidgetProviderInfo for the returned AppWidget, and if it has one, launch its
configuration activity. If Activity.RESULT_CANCELED
is returned, you
should delete the appWidgetId.
ACTION_APPWIDGET_CONFIGURE
,
Constant Field Valuespublic static final String ACTION_APPWIDGET_CONFIGURE
AppWidgetProviderInfo
meta-data
.
The intent will contain the following extras:
EXTRA_APPWIDGET_ID |
The appWidgetId to configure. |
If you return Activity.RESULT_OK
using
Activity.setResult()
, the AppWidget will be added,
and you will receive an ACTION_APPWIDGET_UPDATE
broadcast for this AppWidget.
If you return Activity.RESULT_CANCELED
, the host will cancel the add
and not display this AppWidget, and you will receive a ACTION_APPWIDGET_DELETED
broadcast.
public static final String EXTRA_APPWIDGET_ID
The value will be an int that can be retrieved like this:
public static final String OPTION_APPWIDGET_MIN_WIDTH
public static final String OPTION_APPWIDGET_MIN_HEIGHT
public static final String OPTION_APPWIDGET_MAX_WIDTH
public static final String OPTION_APPWIDGET_MAX_HEIGHT
public static final String OPTION_APPWIDGET_HOST_CATEGORY
AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN
or AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD
or AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX
.public static final String EXTRA_APPWIDGET_OPTIONS
OPTION_APPWIDGET_MIN_WIDTH
,
OPTION_APPWIDGET_MIN_HEIGHT
, OPTION_APPWIDGET_MAX_WIDTH
,
OPTION_APPWIDGET_MAX_HEIGHT
.public static final String EXTRA_APPWIDGET_IDS
The value will be an int array that can be retrieved like this:
public static final String EXTRA_APPWIDGET_PROVIDER
The value will be an ComponentName
.
public static final String EXTRA_APPWIDGET_PROVIDER_PROFILE
The value will be a UserHandle
.
public static final String EXTRA_CUSTOM_INFO
List
of
AppWidgetProviderInfo
objects to mix in to the list of AppWidgets that are
installed. (This is how the launcher shows the search widget).public static final String EXTRA_HOST_ID
ACTION_APPWIDGET_HOST_RESTORED
broadcast,
indicating the integer ID of the host whose widgets have just been restored.public static final String EXTRA_CUSTOM_EXTRAS
List
of
Bundle
objects to mix in to the list of AppWidgets that are
installed. It will be added to the extras object on the Intent
that is returned from the picker activity.
public static final String EXTRA_CATEGORY_FILTER
AppWidgetProviderInfo.widgetCategory
.public static final String EXTRA_CUSTOM_SORT
public static final int INVALID_APPWIDGET_ID
public static final String ACTION_APPWIDGET_UPDATE
This may be sent in response to a new instance for this AppWidget provider having
been instantiated, the requested update interval
having lapsed, or the system booting.
The intent will contain the following extras:
EXTRA_APPWIDGET_IDS |
The appWidgetIds to update. This may be all of the AppWidgets created for this provider, or just a subset. The system tries to send updates for as few AppWidget instances as possible. |
public static final String ACTION_APPWIDGET_OPTIONS_CHANGED
This is a protected intent that can only be sent by the system.
public static final String ACTION_APPWIDGET_DELETED
This is a protected intent that can only be sent by the system.
public static final String ACTION_APPWIDGET_DISABLED
This is a protected intent that can only be sent by the system.
public static final String ACTION_APPWIDGET_ENABLED
This is a protected intent that can only be sent by the system.
public static final String ACTION_APPWIDGET_RESTORED
AppWidgetProvider
after AppWidget state related to that provider has
been restored from backup. The intent contains information about how to translate AppWidget
ids from the restored data to their new equivalents.
The intent will contain the following extras:
EXTRA_APPWIDGET_OLD_IDS |
The set of appWidgetIds represented in a restored backup that have been successfully
incorporated into the current environment. This may be all of the AppWidgets known
to this application, or just a subset. Each entry in this array of appWidgetIds has
a corresponding entry in the EXTRA_APPWIDGET_IDS extra. |
EXTRA_APPWIDGET_IDS |
The set of appWidgetIds now valid for this application. The app should look at
its restored widget configuration and translate each appWidgetId in the
EXTRA_APPWIDGET_OLD_IDS array to its new value found at the corresponding
index within this array. |
This is a protected intent that can only be sent by the system.
public static final String ACTION_APPWIDGET_HOST_RESTORED
The intent will contain the following extras:
EXTRA_APPWIDGET_OLD_IDS |
The set of appWidgetIds represented in a restored backup that have been successfully
incorporated into the current environment. This may be all of the AppWidgets known
to this application, or just a subset. Each entry in this array of appWidgetIds has
a corresponding entry in the EXTRA_APPWIDGET_IDS extra. |
EXTRA_APPWIDGET_IDS |
The set of appWidgetIds now valid for this application. The app should look at
its restored widget configuration and translate each appWidgetId in the
EXTRA_APPWIDGET_OLD_IDS array to its new value found at the corresponding
index within this array. |
EXTRA_HOST_ID |
The integer ID of the widget host instance whose state has just been restored. |
This is a protected intent that can only be sent by the system.
ACTION_APPWIDGET_RESTORED
,
Constant Field Valuespublic static final String EXTRA_APPWIDGET_OLD_IDS
ACTION_APPWIDGET_RESTORED
broadcast intent.
The value will be an int array that can be retrieved like this:
public static final String META_DATA_APPWIDGET_PROVIDER
AppWidgetProviderInfo
,
Constant Field Valuespublic AppWidgetManager(Context context, IAppWidgetService service)
context
- The current context in which to operate.service
- The backing system service.public static AppWidgetManager getInstance(Context context)
Context
object.public void updateAppWidget(int[] appWidgetIds, RemoteViews views)
Note that the RemoteViews parameter will be cached by the AppWidgetService, and hence should
contain a complete representation of the widget. For performing partial widget updates, see
partiallyUpdateAppWidget(int[], RemoteViews)
.
It is okay to call this method both inside an ACTION_APPWIDGET_UPDATE
broadcast,
and outside of the handler.
This method will only work when called from the uid that owns the AppWidget provider.
The total Bitmap memory used by the RemoteViews object cannot exceed that required to fill the screen 1.5 times, ie. (screen width x screen height x 4 x 1.5) bytes.
appWidgetIds
- The AppWidget instances for which to set the RemoteViews.views
- The RemoteViews object to show.public void updateAppWidgetOptions(int appWidgetId, Bundle options)
The extras can be used to embed additional information about this widget to be accessed by the associated widget's AppWidgetProvider.
appWidgetId
- The AppWidget instances for which to set the RemoteViews.options
- The options to associate with this widgetgetAppWidgetOptions(int)
public Bundle getAppWidgetOptions(int appWidgetId)
The extras can be used to embed additional information about this widget to be accessed by the associated widget's AppWidgetProvider.
appWidgetId
- The AppWidget instances for which to set the RemoteViews.updateAppWidgetOptions(int, Bundle)
public void updateAppWidget(int appWidgetId, RemoteViews views)
Note that the RemoteViews parameter will be cached by the AppWidgetService, and hence should
contain a complete representation of the widget. For performing partial widget updates, see
partiallyUpdateAppWidget(int, RemoteViews)
.
It is okay to call this method both inside an ACTION_APPWIDGET_UPDATE
broadcast,
and outside of the handler.
This method will only work when called from the uid that owns the AppWidget provider.
The total Bitmap memory used by the RemoteViews object cannot exceed that required to fill the screen 1.5 times, ie. (screen width x screen height x 4 x 1.5) bytes.
appWidgetId
- The AppWidget instance for which to set the RemoteViews.views
- The RemoteViews object to show.public void partiallyUpdateAppWidget(int[] appWidgetIds, RemoteViews views)
This update differs from updateAppWidget(int[], RemoteViews)
in that the
RemoteViews object which is passed is understood to be an incomplete representation of the
widget, and hence does not replace the cached representation of the widget. As of API
level 17, the new properties set within the views objects will be appended to the cached
representation of the widget, and hence will persist.
Use with RemoteViews.showNext(int)
, RemoteViews.showPrevious(int)
,
RemoteViews.setScrollPosition(int, int)
and similar commands.
It is okay to call this method both inside an ACTION_APPWIDGET_UPDATE
broadcast,
and outside of the handler.
This method will only work when called from the uid that owns the AppWidget provider.
This method will be ignored if a widget has not received a full update via
updateAppWidget(int[], RemoteViews)
.
appWidgetIds
- The AppWidget instances for which to set the RemoteViews.views
- The RemoteViews object containing the incremental update / command.public void partiallyUpdateAppWidget(int appWidgetId, RemoteViews views)
This update differs from updateAppWidget(int, RemoteViews)
in that the RemoteViews
object which is passed is understood to be an incomplete representation of the widget, and
hence is not cached by the AppWidgetService. Note that because these updates are not cached,
any state that they modify that is not restored by restoreInstanceState will not persist in
the case that the widgets are restored using the cached version in AppWidgetService.
Use with RemoteViews.showNext(int)
, RemoteViews.showPrevious(int)
,
RemoteViews.setScrollPosition(int, int)
and similar commands.
It is okay to call this method both inside an ACTION_APPWIDGET_UPDATE
broadcast,
and outside of the handler.
This method will only work when called from the uid that owns the AppWidget provider.
This method will be ignored if a widget has not received a full update via
updateAppWidget(int[], RemoteViews)
.
appWidgetId
- The AppWidget instance for which to set the RemoteViews.views
- The RemoteViews object containing the incremental update / command.public void updateAppWidget(ComponentName provider, RemoteViews views)
It is okay to call this method both inside an ACTION_APPWIDGET_UPDATE
broadcast,
and outside of the handler.
This method will only work when called from the uid that owns the AppWidget provider.
provider
- The ComponentName
for the BroadcastReceiver
provider
for your AppWidget.views
- The RemoteViews object to show.public void notifyAppWidgetViewDataChanged(int[] appWidgetIds, int viewId)
appWidgetIds
- The AppWidget instances to notify of view data changes.viewId
- The collection view id.public void notifyAppWidgetViewDataChanged(int appWidgetId, int viewId)
appWidgetId
- The AppWidget instance to notify of view data changes.viewId
- The collection view id.public List<AppWidgetProviderInfo> getInstalledProvidersForProfile(UserHandle profile)
profile
- The profile for which to get providers. Passing null is equivaled
to passing only the current user handle.Process.myUserHandle()
,
UserManager.getUserProfiles()
public List<AppWidgetProviderInfo> getInstalledProviders()
public List<AppWidgetProviderInfo> getInstalledProviders(int categoryFilter)
categoryFilter
- Will only return providers which register as any of the specified
specified categories. See AppWidgetProviderInfo.widgetCategory
.Process.myUserHandle()
,
UserManager.getUserProfiles()
public List<AppWidgetProviderInfo> getInstalledProvidersForProfile(int categoryFilter, UserHandle profile)
categoryFilter
- Will only return providers which register as any of the specified
specified categories. See AppWidgetProviderInfo.widgetCategory
.profile
- A profile of the current user which to be queried. The user
is itself also a profile. If null, the providers only for the current user
are returned.Process.myUserHandle()
,
UserManager.getUserProfiles()
public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId)
public void bindAppWidgetId(int appWidgetId, ComponentName provider)
You need the BIND_APPWIDGET permission or the user must have enabled binding widgets always for your component. This method is used by the AppWidget picker and should not be used by other apps.
appWidgetId
- The AppWidget instance for which to set the RemoteViews.provider
- The BroadcastReceiver
that will be the AppWidget
provider for this AppWidget.public void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options)
You need the BIND_APPWIDGET permission or the user must have enabled binding widgets always for your component. This method is used by the AppWidget picker and should not be used by other apps.
appWidgetId
- The AppWidget instance for which to set the RemoteViews.provider
- The BroadcastReceiver
that will be the AppWidget
provider for this AppWidget.options
- Bundle containing options for the AppWidget. See also
updateAppWidgetOptions(int, Bundle)
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, ComponentName provider)
You need the BIND_APPWIDGET permission or the user must have enabled binding
widgets always for your component. Should be used by apps that host widgets; if this
method returns false, call ACTION_APPWIDGET_BIND
to request permission to
bind
appWidgetId
- The AppWidget id under which to bind the provider.provider
- The BroadcastReceiver
that will be the AppWidget
provider for this AppWidget.public boolean bindAppWidgetIdIfAllowed(int appWidgetId, ComponentName provider, Bundle options)
You need the BIND_APPWIDGET permission or the user must have enabled binding
widgets always for your component. Should be used by apps that host widgets; if this
method returns false, call ACTION_APPWIDGET_BIND
to request permission to
bind
appWidgetId
- The AppWidget id under which to bind the provider.provider
- The BroadcastReceiver
that will be the AppWidget
provider for this AppWidget.options
- Bundle containing options for the AppWidget. See also
updateAppWidgetOptions(int, Bundle)
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, UserHandle user, ComponentName provider, Bundle options)
Note: You need the android.Manifest.permission#BIND_APPWIDGET
permission or the user must have enabled binding widgets always for your component.
Should be used by apps that host widgets. If this method returns false, call ACTION_APPWIDGET_BIND
to request permission to bind.
appWidgetId
- The AppWidget id under which to bind the provider.user
- The user id in which the provider resides.provider
- The component name of the provider.options
- An optional Bundle containing options for the AppWidget.public boolean hasBindAppWidgetPermission(String packageName, int userId)
You need the MODIFY_APPWIDGET_BIND_PERMISSIONS permission
packageName
- The package for which the permission is being querieduserId
- The user id of the user under which the package runs.public boolean hasBindAppWidgetPermission(String packageName)
You need the MODIFY_APPWIDGET_BIND_PERMISSIONS permission
packageName
- The package for which the permission is being queriedpublic void setBindAppWidgetPermission(String packageName, boolean permission)
You need the MODIFY_APPWIDGET_BIND_PERMISSIONS permission
packageName
- The package whose permission is being changedpermission
- Whether to give the package permission to bind widgetspublic void setBindAppWidgetPermission(String packageName, int userId, boolean permission)
You need the MODIFY_APPWIDGET_BIND_PERMISSIONS permission
packageName
- The package whose permission is being changeduserId
- The user under which the package is running.permission
- Whether to give the package permission to bind widgetspublic void bindRemoteViewsService(String packageName, int appWidgetId, Intent intent, IBinder connection)
AppWidgetManager.bindAppWidgetId()
.packageName
- The package from which the binding is requested.appWidgetId
- The AppWidget instance for which to bind the RemoteViewsService.intent
- The intent of the service which will be providing the data to the
RemoteViewsAdapter.connection
- The callback interface to be notified when a connection is made or lost.public void unbindRemoteViewsService(String packageName, int appWidgetId, Intent intent)
AppWidgetManager.bindAppWidgetId()
.packageName
- The package from which the binding is requested.appWidgetId
- The AppWidget instance for which to bind the RemoteViewsService.intent
- The intent of the service which will be providing the data to the
RemoteViewsAdapter.public int[] getAppWidgetIds(ComponentName provider)
provider
- The BroadcastReceiver
that is the
AppWidget provider to find appWidgetIds for.public boolean isBoundWidgetPackage(String packageName, int userId)