本文整理汇总了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);
}