Methods Summary |
---|
public int | allocateAppWidgetId()Get a appWidgetId for a host in the calling process.
try {
if (mPackageName == null) {
mPackageName = mContext.getPackageName();
}
return sService.allocateAppWidgetId(mPackageName, mHostId);
}
catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
|
public final AppWidgetHostView | createView(android.content.Context context, int appWidgetId, AppWidgetProviderInfo appWidget)
AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget);
view.setAppWidget(appWidgetId, appWidget);
synchronized (mViews) {
mViews.put(appWidgetId, view);
}
RemoteViews views = null;
try {
views = sService.getAppWidgetViews(appWidgetId);
} catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
view.updateAppWidget(views);
return view;
|
public static void | deleteAllHosts()Remove all records about all hosts for your package.
- 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.
try {
sService.deleteAllHosts();
}
catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
|
public void | deleteAppWidgetId(int appWidgetId)Stop listening to changes for this AppWidget.
synchronized (mViews) {
mViews.remove(appWidgetId);
try {
sService.deleteAppWidgetId(appWidgetId);
}
catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
}
|
public void | deleteHost()Remove all records about this host from the AppWidget manager.
- 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.
try {
sService.deleteHost(mHostId);
}
catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
|
protected AppWidgetHostView | onCreateView(android.content.Context context, int appWidgetId, AppWidgetProviderInfo appWidget)Called to create the AppWidgetHostView. Override to return a custom subclass if you
need it. {@more}
return new AppWidgetHostView(context);
|
protected void | onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget)Called when the AppWidget provider for a AppWidget has been upgraded to a new apk.
|
public void | startListening()Start receiving onAppWidgetChanged calls for your AppWidgets. Call this when your activity
becomes visible, i.e. from onStart() in your Activity.
int[] updatedIds = null;
ArrayList<RemoteViews> updatedViews = new ArrayList();
try {
if (mPackageName == null) {
mPackageName = mContext.getPackageName();
}
updatedIds = sService.startListening(mCallbacks, mPackageName, mHostId, updatedViews);
}
catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
final int N = updatedIds.length;
for (int i=0; i<N; i++) {
updateAppWidgetView(updatedIds[i], updatedViews.get(i));
}
|
public void | stopListening()Stop receiving onAppWidgetChanged calls for your AppWidgets. Call this when your activity is
no longer visible, i.e. from onStop() in your Activity.
try {
sService.stopListening(mHostId);
}
catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
|
void | updateAppWidgetView(int appWidgetId, android.widget.RemoteViews views)
AppWidgetHostView v;
synchronized (mViews) {
v = mViews.get(appWidgetId);
}
if (v != null) {
v.updateAppWidget(views);
}
|