android-App Widget Host

bindAppWidgetIdIfAllowed()allocateAppWidgetId()AppWidgetHostView updateAppWidgetOptions() and updateAppWidgetSize()

Regardless of the version of Android you are targeting, all hosts have the following responsibilities:

  • When adding a widget, you must allocate the widget ID as described above. You must also make sure that when a widget is removed from the host, you call deleteAppWidgetId() to deallocate the widget ID.
  • When adding a widget, be sure to launch its configuration activity if it exists, as described in Updating the App Widget from the Configuration Activity. This is a necessary step for many app widgets before they can be properly displayed.
  • Every app widget specifies a minimum width and height in dps, as defined in the AppWidgetProviderInfo metadata (usingandroid:minWidth and android:minHeight). Make sure that the widget is laid out with at least this many dps. For example, many hosts align icons and widgets in a grid. In this scenario, by default the host should add the app widget using the minimum number of cells that satisfy the minWidth andminHeight constraints.

你可能感兴趣的:(Android,编程)