本文整理匯總了Java中android.appwidget.AppWidgetManager.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java AppWidgetManager.getInstance方法的具體用法?Java AppWidgetManager.getInstance怎麽用?Java AppWidgetManager.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.appwidget.AppWidgetManager
的用法示例。
在下文中一共展示了AppWidgetManager.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceive
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
AppWidgetManager mgr = AppWidgetManager.getInstance(context);
if (intent.getAction().equals(WIDGET_ACTION)) {
int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
int viewIndex = intent.getIntExtra(EXTRA_ITEM, 0);
List<Hit> mWidgetItems = CanvasDownloadTable.getRows(context.getContentResolver().query(CanvasDownloadTable.CONTENT_URI, null, null, null, null), true);
Intent intent_detail = new Intent(context, PicDetail.class);
intent_detail.putExtra(PicDetail.EXTRA_PIC, mWidgetItems.get(viewIndex));
intent_detail.putExtra(PicDetail.origin,context.getResources().getString(R.string.widget));
intent_detail.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent_detail);
}
super.onReceive(context, intent);
}
示例2: onReceive
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
@Override
public void onReceive(final Context context, Intent widgetIntent) {
final String action = widgetIntent.getAction();
if (REFRESH_ACTION.equals(action)) {
LOGD(TAG, "received REFRESH_ACTION from widget");
final boolean shouldSync = widgetIntent.getBooleanExtra(EXTRA_PERFORM_SYNC, false);
// Trigger sync
Account chosenAccount = AccountUtils.getActiveAccount(context);
if (shouldSync && chosenAccount != null) {
SyncHelper.requestManualSync(chosenAccount);
}
// Notify the widget that the list view needs to be updated.
final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
final ComponentName cn = new ComponentName(context, ScheduleWidgetProvider.class);
mgr.notifyAppWidgetViewDataChanged(mgr.getAppWidgetIds(cn),
R.id.widget_schedule_list);
}
super.onReceive(context, widgetIntent);
}
示例3: pushUpdate
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private void pushUpdate(Context context, int[] appWidgetIds, RemoteViews views) {
// Update specific list of appWidgetIds if given, otherwise default to all
final AppWidgetManager gm = AppWidgetManager.getInstance(context);
if (appWidgetIds != null) {
gm.updateAppWidget(appWidgetIds, views);
} else {
gm.updateAppWidget(new ComponentName(context, this.getClass()), views);
}
}
示例4: pushUpdate
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private void pushUpdate(Context context, int[] appWidgetIds,
RemoteViews views) {
// Update specific list of appWidgetIds if given, otherwise default to
// all
final AppWidgetManager gm = AppWidgetManager.getInstance(context);
if (appWidgetIds != null) {
gm.updateAppWidget(appWidgetIds, views);
} else {
gm.updateAppWidget(new ComponentName(context, this.getClass()),
views);
}
}
示例5: update
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
/**
* Updates the AppWidget after the ImageView has loaded the Bitmap.
*/
private void update() {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this.context);
if (this.componentName != null) {
appWidgetManager.updateAppWidget(this.componentName, this.remoteViews);
} else {
appWidgetManager.updateAppWidget(this.widgetIds, this.remoteViews);
}
}
示例6: onReceive
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if (intent.getAction().equals(ACTION_DATA_UPDATED)) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
new ComponentName(context, getClass()));
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);
}
}
示例7: updateWidget
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
public void updateWidget() {
Intent intent = new Intent(this, BuddyBookWidgetProvider.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
// Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID,
// since it seems the onUpdate() is only fired on that:
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
int appWidgetIds[] = appWidgetManager
.getAppWidgetIds(new ComponentName(mContext, BuddyBookWidgetProvider.class));
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
sendBroadcast(intent);
}
示例8: pushUpdate
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private void pushUpdate(final Context context, final int[] appWidgetIds, final RemoteViews views) {
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
if (appWidgetIds != null) {
appWidgetManager.updateAppWidget(appWidgetIds, views);
} else {
appWidgetManager.updateAppWidget(new ComponentName(context, getClass()), views);
}
}
示例9: hasInstances
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
/**
* Check against {@link AppWidgetManager} if there are any instances of this
* widget.
*/
private boolean hasInstances(Context context) {
AppWidgetManager appWidgetManager = AppWidgetManager
.getInstance(context);
int[] appWidgetIds = appWidgetManager
.getAppWidgetIds(new ComponentName(context, this.getClass()));
return (appWidgetIds.length > 0);
}
示例10: onReceive
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
int[] appWidgetIDs;
if (intent.getAction().equals(ACTION_UPDATE)) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
appWidgetIDs = appWidgetManager.getAppWidgetIds(new ComponentName(context, getClass()));
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIDs, R.id.newsList);
}
}
開發者ID:vikasdesale,項目名稱:News24x7-news-from-every-part-of-the-world,代碼行數:11,代碼來源:NewsWidgetProvider.java
示例11: hasInstances
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private boolean hasInstances(Context context) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, this.getClass()));
return (appWidgetIds.length > 0);
}
示例12: PingAsyncTask
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
public PingAsyncTask(Context appContext, int widgetId) {
mAppContext = appContext;
mWidgetId = widgetId;
mAppWidgetManager = AppWidgetManager.getInstance(appContext);
}
示例13: AppWidgetManagerCompat
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
AppWidgetManagerCompat(Context context) {
mContext = context;
mAppWidgetManager = AppWidgetManager.getInstance(context);
}
示例14: findAppWidgetIds
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private static int[] findAppWidgetIds(Context context) {
AppWidgetManager manager = AppWidgetManager.getInstance(context);
ComponentName widget = new ComponentName(context, RecordingWidgetProvider.class);
return manager.getAppWidgetIds(widget);
}
示例15: handleActionUpdateWidgets
import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private void handleActionUpdateWidgets(Recipe recipe) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(this, RecipeWidgetProvider.class));
RecipeWidgetProvider.updateRecipeWidgets(this, appWidgetManager, recipe, appWidgetIds);
}