当前位置: 首页>>代码示例>>Java>>正文


Java AppWidgetManager.notifyAppWidgetViewDataChanged方法代码示例

本文整理汇总了Java中android.appwidget.AppWidgetManager.notifyAppWidgetViewDataChanged方法的典型用法代码示例。如果您正苦于以下问题:Java AppWidgetManager.notifyAppWidgetViewDataChanged方法的具体用法?Java AppWidgetManager.notifyAppWidgetViewDataChanged怎么用?Java AppWidgetManager.notifyAppWidgetViewDataChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.appwidget.AppWidgetManager的用法示例。


在下文中一共展示了AppWidgetManager.notifyAppWidgetViewDataChanged方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateAppWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.schedule_daily_widget);

    Intent intent = new Intent(context, ScheduleDailyService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
    views.setRemoteAdapter(appWidgetId, R.id.list_item, intent);

    views.setViewVisibility(R.id.sync_instruction, IS_NOT_READY_YET ? TextView.VISIBLE : TextView.GONE);


    Intent launchMain = new Intent(context, MainActivity.class);
    PendingIntent pendingMainIntent = PendingIntent.getActivity(context, 0, launchMain, 0);
    views.setOnClickPendingIntent(R.id.widget_daily, pendingMainIntent);

    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list_item);
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:mgilangjanuar,项目名称:GoSCELE,代码行数:19,代码来源:ScheduleDailyWidget.java

示例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);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:24,代码来源:ScheduleWidgetProvider.java

示例3: performUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void performUpdate(Context context,
        AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int appWidgetId : appWidgetIds) {
        Intent updateIntent = new Intent(context, BookmarkWidgetService.class);
        updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        updateIntent.setData(Uri.parse(updateIntent.toUri(Intent.URI_INTENT_SCHEME)));

        int layoutId = shouldShowIconsOnly(appWidgetManager, appWidgetId)
                ? R.layout.bookmark_widget_icons_only
                : R.layout.bookmark_widget;
        RemoteViews views = new RemoteViews(context.getPackageName(), layoutId);
        views.setRemoteAdapter(R.id.bookmarks_list, updateIntent);

        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.bookmarks_list);
        Intent ic = new Intent(context, BookmarkWidgetProxy.class);
        views.setPendingIntentTemplate(R.id.bookmarks_list,
                PendingIntent.getBroadcast(context, 0, ic,
                PendingIntent.FLAG_UPDATE_CURRENT));
        appWidgetManager.updateAppWidget(appWidgetId, views);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:BookmarkWidgetProvider.java

示例4: updateAppWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.monolith_widget);

    // Intent to launch MainActivity
    final Intent onItemClick = new Intent(context, MonolithWidget.class);
    onItemClick.setAction(ACTION_WIDGET_CLICK);
    if (intent != null) {
        onItemClick.setData(intent.getData());
        Log.e("Content not null", "updateAppWidget: " + intent.getData());
    }
    PendingIntent onClickPendingIntent = PendingIntent
            .getBroadcast(context, 0, onItemClick,
                    PendingIntent.FLAG_UPDATE_CURRENT);
    views.setPendingIntentTemplate(R.id.widget_list,
            onClickPendingIntent);
    views.setRemoteAdapter(R.id.widget_list,
            new Intent(context, WidgetService.class));
    views.setEmptyView(R.id.widget_list, R.id.widget_empty);

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list);
}
 
开发者ID:prshntpnwr,项目名称:Monolith,代码行数:26,代码来源:MonolithWidget.java

示例5: onReceive

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    MonolithWidget.intent = intent;
    Log.d(TAG, "onReceive is called");
    if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(intent.getAction())) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
                new ComponentName(context, getClass()));
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.monolith_widget);
        appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);
    }

    if (intent.getAction().equals(ACTION_WIDGET_CLICK)) {
        Log.e(TAG, "onReceive: Intent has ACTION_WIDGET_CLICK");
        Bundle bundle = new Bundle();
        bundle.putString(context.getResources().getString(R.string.title), intent.getStringExtra(context.getResources().getString(R.string.title)));
        bundle.putString(context.getResources().getString(R.string.date), intent.getStringExtra("date"));
        bundle.putString(context.getResources().getString(R.string.image), intent.getStringExtra("image"));
        bundle.putString(context.getResources().getString(R.string.description), intent.getStringExtra("description"));
        bundle.putString(context.getResources().getString(R.string.link), intent.getStringExtra(context.getResources().getString(R.string.link)));
        Intent intent1 = new Intent(context, ArticleDetailActivity.class);
        intent1.putExtras(bundle);
        intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent1);
    }
}
 
开发者ID:prshntpnwr,项目名称:Monolith,代码行数:29,代码来源:MonolithWidget.java

示例6: onReceive

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);

    String action = intent.getAction();
    if (action.equals(ACTION_UPDATE_MESSAGE_LIST)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        int[] appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.listView);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:MessageListWidgetProvider.java

示例7: onReceive

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    String action = intent.getAction();
    if (REFRESH_ACTION.equals(action)) {
        AppWidgetManager manager = AppWidgetManager.getInstance(context);
        ComponentName name = new ComponentName(context, AppWidgetProvider.class);
        manager.notifyAppWidgetViewDataChanged(manager.getAppWidgetIds(name), R.id.listViewWidget);
    }
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:11,代码来源:AppWidgetProvider.java

示例8: 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

示例9: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@SuppressLint("PrivateResource")
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int widgetId : appWidgetIds) {
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.buddy_widget_list);


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            setRemoteAdapter(context, remoteViews);
        } else {
            setRemoteAdapterV11(context, remoteViews);
        }

        Intent clickIntentTemplate = new Intent(context, DetailActivity.class);

        PendingIntent pendingIntentTemplate = TaskStackBuilder.create(context)
                .addNextIntentWithParentStack(clickIntentTemplate)
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

        remoteViews.setPendingIntentTemplate(R.id.widget_list, pendingIntentTemplate);
        remoteViews.setEmptyView(R.id.widget_list, R.id.widget_empty);
        remoteViews.setContentDescription(R.id.widget_list, context.getString(R.string.widget_cd));
        appWidgetManager.updateAppWidget(widgetId, remoteViews);

        appWidgetManager.notifyAppWidgetViewDataChanged(widgetId, R.id.widget_list);

    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:30,代码来源:BuddyBookWidgetProvider.java

示例10: updateWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void updateWidget() {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
    int appWidgetIds[] = appWidgetManager
            .getAppWidgetIds(new ComponentName(mContext, BuddyBookWidgetProvider.class));
    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);

}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:8,代码来源:BuddyBookWidgetService.java

示例11: handleIngredientsListRefreshAction

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void handleIngredientsListRefreshAction() {
    Recipe userSelectedRecipe = Recipe.builder().build();

    try {
        userSelectedRecipe = recipesRepository.getRecipeForWidgetDisplay().blockingGet();
    } catch (RuntimeException exception) {
        Timber.e(exception.getMessage());
    }

    AppWidgetManager widgetManager = AppWidgetManager.getInstance(this);
    int[] widgetsIds = widgetManager.getAppWidgetIds(new ComponentName(this, IngredientsWidgetProvider.class));
    widgetManager.notifyAppWidgetViewDataChanged(widgetsIds, R.id.ingredients_widget_list_view);

    IngredientsWidgetProvider.update(this, widgetManager, widgetsIds, userSelectedRecipe);
}
 
开发者ID:ecarrara-araujo,项目名称:yabaking,代码行数:16,代码来源:IngredientsRefreshService.java

示例12: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
/**
 * Function fire on system update widget
 *
 * @param context          Context of application
 * @param appWidgetManager App widget manger
 * @param appWidgetIds     Widget system ids
 */
@Override
public void onUpdate(Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    final int count = appWidgetIds.length;

    //set widget language with the system language
    Locale locale = new Locale(Resources.getSystem().getConfiguration().locale.getLanguage());
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
    this.context = context;

    //loop in all widgets
    for (int i = 0; i < count; i++) {
        svcIntent = new Intent(context, CalenderRemoteViewsService.class);
        final int widgetId = appWidgetIds[i];
        remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_calender);
        remoteViews.setRemoteAdapter(R.id.calendar_pager, svcIntent);
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds[i], R.id.calendar_pager);
        HGDate hgDate = new HGDate();
        hgDate.toHigri();
        remoteViews.setTextViewText(R.id.textView8, Dates.getCurrentWeekDay());
        remoteViews.setTextViewText(R.id.textView7, NumbersLocal.convertToNumberTypeSystem(context, hgDate.getDay() + ""));
        remoteViews.setTextViewText(R.id.textView24, NumbersLocal.convertToNumberTypeSystem(context, hgDate.getYear() + ""));
        remoteViews.setTextViewText(R.id.curr_month_txt, Dates.islamicMonthName(context, hgDate.getMonth() - 1));
        remoteViews.setTextViewText(R.id.curr_month_txt_other, showOtherMonth(hgDate));

        PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
        remoteViews.setOnClickPendingIntent(R.id.relativeLayout, configPendingIntent);
        appWidgetManager.updateAppWidget(widgetId, remoteViews);

    }
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:41,代码来源:CalenderWidget.java

示例13: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int appWidgetId : appWidgetIds) {
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_detail);

        // Create an Intent to launch MainActivity for example when clicking on the title
        Intent intent = new Intent(context, FavoriteMovieActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
        rv.setOnClickPendingIntent(R.id.widget, pendingIntent);


        Log.d("ArticleWidgetProvider", "onUpdate called: ");
        // Set up the collection
        setRemoteAdapter(context, rv);


        Intent clickIntentTemplate = new Intent(context, DetailActivity.class);
        PendingIntent clickPendingIntentTemplate = TaskStackBuilder.create(context)
                .addNextIntentWithParentStack(clickIntentTemplate)
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.widget_list_new, clickPendingIntentTemplate);
        rv.setEmptyView(R.id.widget_list_new, R.id.widget_empty);


        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list_new);
        // Tell the AppWidgetManager to perform an update on the current app widget
        appWidgetManager.updateAppWidget(appWidgetId, rv);

    }
}
 
开发者ID:ansh94,项目名称:DailyTech,代码行数:33,代码来源:ArticleWidgetProvider.java

示例14: updateListContents

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private static void updateListContents(Context context) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, "updateListContents");

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);

    ComponentName thisAppWidgetComponentName = new ComponentName(context.getPackageName(), ListWidgetProvider.class.getName());
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidgetComponentName);
    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.list_widget_list_view);
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:10,代码来源:ListWidgetProvider.java

示例15: setFilterFromIntent

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private static void setFilterFromIntent(Context context, Intent intent) {
    int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    long filterId = intent.getLongExtra(AppIntent.EXTRA_SAVED_SEARCH_ID, 0);

    setFilter(context, appWidgetId, filterId);

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    updateAppWidgetLayout(context, appWidgetManager, appWidgetId);
    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list_widget_list_view);
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:11,代码来源:ListWidgetProvider.java


注:本文中的android.appwidget.AppWidgetManager.notifyAppWidgetViewDataChanged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。