Most visited

Recently visited

Added in API level 3

AppWidgetHost

public class AppWidgetHost
extends Object

java.lang.Object
   ↳ android.appwidget.AppWidgetHost


AppWidgetHost为AppWidget服务提供了与AppWidget服务的交互,例如主屏幕,它们想要将AppWidgets嵌入到他们的UI中。

Summary

Public constructors

AppWidgetHost(Context context, int hostId)

Public methods

int allocateAppWidgetId()

在调用过程中获取主机的appWidgetId。

final AppWidgetHostView createView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget)

为给定的小部件创建AppWidgetHostView。

static void deleteAllHosts()

删除有关您的软件包的所有主机的所有记录。

void deleteAppWidgetId(int appWidgetId)

停止收听此AppWidget的更改。

void deleteHost()

从AppWidget管理器中删除有关该主机的所有记录。

final void startAppWidgetConfigureActivityForResult(Activity activity, int appWidgetId, int intentFlags, int requestCode, Bundle options)

代表调用者开始一个应用窗口小部件提供程序配置活动。

void startListening()

开始接收您的AppWidgets的onAppWidgetChanged调用。

void stopListening()

停止接收AppWidgets的onAppWidgetChanged调用。

Protected methods

void clearViews()

清除已由此AppWidgetHost创建的视图列表。

AppWidgetHostView onCreateView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget)

调用来创建AppWidgetHostView。 如果需要,重写以返回自定义子类。

void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget)

当AppWidget的AppWidget提供者已升级为新的apk时调用。

void onProvidersChanged()

当可用小部件集发生变化时调用(即。

Inherited methods

From class java.lang.Object

Public constructors

AppWidgetHost

Added in API level 3
AppWidgetHost (Context context, 
                int hostId)

Parameters
context Context
hostId int

Public methods

allocateAppWidgetId

Added in API level 3
int allocateAppWidgetId ()

在调用过程中获取主机的appWidgetId。

Returns
int a appWidgetId

createView

Added in API level 3
AppWidgetHostView createView (Context context, 
                int appWidgetId, 
                AppWidgetProviderInfo appWidget)

为给定的小部件创建AppWidgetHostView。 AppWidgetHost保留一个指向新创建的视图的指针。

Parameters
context Context
appWidgetId int
appWidget AppWidgetProviderInfo
Returns
AppWidgetHostView

deleteAllHosts

Added in API level 3
void deleteAllHosts ()

删除有关您的软件包的所有主机的所有记录。

  • Call this when initializing your database, as it might be because of a data wipe.
  • Call this to have the AppWidget manager release all resources associated with your host. Any future calls about this host will cause the records to be re-allocated.

deleteAppWidgetId

Added in API level 3
void deleteAppWidgetId (int appWidgetId)

停止收听此AppWidget的更改。

Parameters
appWidgetId int

deleteHost

Added in API level 3
void deleteHost ()

从AppWidget管理器中删除有关该主机的所有记录。

  • Call this when initializing your database, as it might be because of a data wipe.
  • Call this to have the AppWidget manager release all resources associated with your host. Any future calls about this host will cause the records to be re-allocated.

startAppWidgetConfigureActivityForResult

Added in API level 21
void startAppWidgetConfigureActivityForResult (Activity activity, 
                int appWidgetId, 
                int intentFlags, 
                int requestCode, 
                Bundle options)

代表调用者开始一个应用窗口小部件提供程序配置活动。 如果提供者位于其他配置文件中,请使用此方法,因为您不允许在其他配置文件中启动活动。 您可以选择提供onActivityResult(int, int, android.content.Intent)返回的请求代码以及要传递给启动活动的选项包。

请注意,提供的应用程序小部件必须绑定此方法才能工作。

Parameters
activity Activity: The activity from which to start the configure one.
appWidgetId int: The bound app widget whose provider's config activity to start.
intentFlags int: Optional intent flags.
requestCode int: Optional request code retuned with the result.
options Bundle
Throws
ActivityNotFoundException If the activity is not found.

也可以看看:

startListening

Added in API level 3
void startListening ()

开始接收您的AppWidgets的onAppWidgetChanged调用。 当你的活动变得可见时调用这个,例如从Activity的onStart()。

stopListening

Added in API level 3
void stopListening ()

停止接收AppWidgets的onAppWidgetChanged调用。 当你的活动不再可见时,例如从你的Activity的onStop()中调用它。

Protected methods

clearViews

Added in API level 11
void clearViews ()

清除已由此AppWidgetHost创建的视图列表。

onCreateView

Added in API level 3
AppWidgetHostView onCreateView (Context context, 
                int appWidgetId, 
                AppWidgetProviderInfo appWidget)

调用来创建AppWidgetHostView。 如果需要,重写以返回自定义子类。

Parameters
context Context
appWidgetId int
appWidget AppWidgetProviderInfo
Returns
AppWidgetHostView

onProviderChanged

Added in API level 3
void onProviderChanged (int appWidgetId, 
                AppWidgetProviderInfo appWidget)

当AppWidget的AppWidget提供者已升级为新的apk时调用。

Parameters
appWidgetId int
appWidget AppWidgetProviderInfo

onProvidersChanged

Added in API level 17
void onProvidersChanged ()

当可用小部件集发生更改时调用(即包含包的小部件被添加,更新或删除,或者小部件组件已启用或禁用)。

Hooray!