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


Java AppWidgetManager.updateAppWidget方法代码示例

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


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

示例1: updateAppWidget

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

    CharSequence widgetText = HiAppWidgetConfigureActivity.loadTitlePref(context, appWidgetId);
    int pos = HiAppWidgetConfigureActivity.loadPosPref(context, appWidgetId) % texts.length;
    // Construct the RemoteViews object
    int layoutId = pos == 3 ? R.layout.hi_app_widget_other : R.layout.hi_app_widget;
    RemoteViews views = new RemoteViews(context.getPackageName(), layoutId);
    views.setTextViewText(R.id.title, widgetText);
    views.setTextViewText(R.id.appwidget_text, context.getString(texts[pos]));

    views.setOnClickPendingIntent(R.id.back, getPendingIntent(context, appWidgetId, -1));
    views.setOnClickPendingIntent(R.id.next, getPendingIntent(context, appWidgetId, +1));

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:UTN-FRBA-Mobile,项目名称:Clases-2017c1,代码行数:18,代码来源:HiAppWidget.java

示例2: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // update each of the widgets with the remote adapter
    for (int i = 0; i < appWidgetIds.length; ++i) {

        // Here we setup the intent which points to the StackViewService which will
        // provide the views for this collection.
        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        // When intents are compared, the extras are ignored, so we need to embed the extras
        // into the data so that the extras will not be ignored.
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
        rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

        // The empty view is displayed when the collection has no items. It should be a sibling
        // of the collection view.
        rv.setEmptyView(R.id.stack_view, R.id.empty_view);

        // Here we setup the a pending intent template. Individuals items of a collection
        // cannot setup their own pending intents, instead, the collection as a whole can
        // setup a pending intent template, and the individual items can set a fillInIntent
        // to create unique before on an item to item basis.
        Intent toastIntent = new Intent(context, StackWidgetProvider.class);
        toastIntent.setAction(StackWidgetProvider.TOAST_ACTION);
        toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:36,代码来源:StackWidgetProvider.java

示例3: updateWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void updateWidget() {
        //获取WidgetManager对象
        AppWidgetManager awm = AppWidgetManager.getInstance(this);
        //使用RemoteViews远程更新控件
        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.process_widget);
        if (mBitmap_icon != null) {
            remoteViews.setImageViewBitmap(R.id.iv_icon, mBitmap_icon);
        }
        remoteViews.setTextViewText(R.id.tv_publis_time, mPublishTime);
        remoteViews.setTextViewText(R.id.tv_temp, mCurrentTemp);
        remoteViews.setTextViewText(R.id.tv_city, mCurrentCity);


        //点击小部件的进程总数和剩余控件总数的textview处,跳转到应用的主界面处
        Intent i = new Intent("android.intent.action.HOME");
        i.addCategory("android.intent.category.DEFAULT");
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
        remoteViews.setOnClickPendingIntent(R.id.fl_icon, pendingIntent);

//        让AppWidgetManager更新小部件的内容
        ComponentName componentName = new ComponentName(this, MyAppWidgetProvider.class);
        awm.updateAppWidget(componentName, remoteViews);
    }
 
开发者ID:BlueLeer,项目名称:XiaoTianQi,代码行数:24,代码来源:AppWidgetService.java

示例4: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int i = 0; i < appWidgetIds.length; ++i) {

        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
        rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

        rv.setEmptyView(R.id.stack_view, R.id.empty_view);

        Intent widgetIntent = new Intent(context, StackWidgetProvider.class);
        widgetIntent.setAction(StackWidgetProvider.WIDGET_ACTION);
        widgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent widgetPendingIntent = PendingIntent.getBroadcast(context, 0, widgetIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, widgetPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:25,代码来源:StackWidgetProvider.java

示例5: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    for (int appWidgetId : appWidgetIds) {

        RemoteViews widgetViews = new RemoteViews(context.getPackageName(), R.layout.news_widget);
        Intent svcIntent = new Intent(context, NewsWidgetService.class);
        svcIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);

        svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
        widgetViews.setRemoteAdapter(R.id.newsList, svcIntent);
        widgetViews.setEmptyView(R.id.newsList, R.id.emptyMessage);

        Intent clickAppIntent = new Intent(context, HomeActivity.class);
        Intent clickIntent = new Intent(context, DetailsActivity.class);
        PendingIntent appPI = PendingIntent.getActivity(context, 0, clickAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        PendingIntent clickPI = PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        widgetViews.setOnClickPendingIntent(R.id.newsTitle, appPI);
        widgetViews.setPendingIntentTemplate(R.id.newsList, clickPI);

        appWidgetManager.updateAppWidget(appWidgetId, widgetViews);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:vikasdesale,项目名称:News24x7-news-from-every-part-of-the-world,代码行数:27,代码来源:NewsWidgetProvider.java

示例6: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
                     int[] appWidgetIds) {

        Intent receiver = new Intent(context, FlashlightWidgetReceiver.class);
        receiver.setAction("COM_FLASHLIGHT");
        receiver.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, receiver, 0);

        RemoteViews views = new RemoteViews(context.getPackageName(),
                        R.layout.flash_light_widget);
        views.setOnClickPendingIntent(R.id.button, pendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds, views);

}
 
开发者ID:hiteshsahu,项目名称:Android-Photo-Cell-POC,代码行数:17,代码来源:FlashlightWidgetProvider.java

示例7: updateAppWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
protected void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.up_down_widget);
    views.setOnClickPendingIntent(R.id.up_btn,
            PendingIntent.getBroadcast(context, 0, new Intent(ArcadeCommon.ACTION_UP), 0));
    views.setOnClickPendingIntent(R.id.down_btn,
            PendingIntent.getBroadcast(context, 0, new Intent(ArcadeCommon.ACTION_DOWN), 0));
            
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:11,代码来源:UpDownWidget.java

示例8: 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);
    }
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:14,代码来源:MediaAppWidgetProvider4x1_Light.java

示例9: updateAppWidget

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

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.horario_widget);
    //views.setTextViewText(R.id.appwidget_text, "");

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:Onelio,项目名称:ConnectU,代码行数:10,代码来源:HorarioWidget.java

示例10: 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);
    }
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:13,代码来源:MediaAppWidgetProvider4x4_Light.java

示例11: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    LOGD(TAG, "updating app widget");
    final boolean isAuthenticated = AccountUtils.hasActiveAccount(context);
    for (int appWidgetId : appWidgetIds) {
        // Specify the service to provide data for the collection widget.  Note that we need to
        // embed the appWidgetId via the data otherwise it will be ignored.
        final Intent intent = new Intent(context, ScheduleWidgetRemoteViewsService.class)
                .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        final RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget);
        rv.setRemoteAdapter(R.id.widget_schedule_list, intent);

        // Set the empty view to be displayed if the collection is empty.  It must be a sibling
        // view of the collection view.
        rv.setEmptyView(R.id.widget_schedule_list, android.R.id.empty);
        LOGD(TAG, "setting widget empty view");
        rv.setTextViewText(android.R.id.empty, context.getResources().getString(isAuthenticated
                ? R.string.empty_widget_text
                : R.string.empty_widget_text_signed_out));

        final PendingIntent refreshPendingIntent = PendingIntent.getBroadcast(context, 0,
                getRefreshBroadcastIntent(context, true), PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent(R.id.widget_refresh_button, refreshPendingIntent);

        final Intent onClickIntent = TaskStackBuilderProxyActivity.getTemplate(context);
        final PendingIntent onClickPendingIntent = PendingIntent.getActivity(context, 0,
                onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.widget_schedule_list, onClickPendingIntent);

        final Intent openAppIntent = new Intent(context, MyScheduleActivity.class)
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        final PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0,
                openAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent(R.id.widget_logo, openAppPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetId, rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:41,代码来源:ScheduleWidgetProvider.java

示例12: onWidgetUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void onWidgetUpdate(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
    Intent intent = new Intent();
    intent.setAction(CLICK_ACTION);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
    remoteViews.setOnClickPendingIntent(R.id.imageview, pendingIntent);
    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);

}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:10,代码来源:MyAppWidgetProvider.java

示例13: updateAppWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
public static void updateAppWidget(AppWidgetManager manager, Context context, int appWidgetId, String repositoryName, String uuid) {
    RemoteViews views = createRemoteViews(context, appWidgetId, repositoryName, uuid);

    // Service intent, sent to WidgetListFactory
    Intent svcIntent = new Intent(context, WidgetService.class);
    svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    svcIntent.putExtra(KEY_TODO_LIST, repositoryName);
    svcIntent.putExtra(KEY_UUID, uuid);
    svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
    views.setRemoteAdapter(R.id.widget_list_view, svcIntent);
    manager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:13,代码来源:TodoListAppWidgetProvider.java

示例14: onUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    Log.d(TAG, "onUpdate");
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    context.startService(new Intent(context, ClockScreenService.class));
    RemoteViews mainWidgetView = new RemoteViews(context.getPackageName(), R.layout.widget_main);
    setupView(context, mainWidgetView);

    appWidgetManager.updateAppWidget(appWidgetIds, null);
    appWidgetManager.updateAppWidget(appWidgetIds, mainWidgetView);

}
 
开发者ID:WeAreFairphone,项目名称:android_packages_apps_ClockWidget,代码行数:14,代码来源:ClockWidget.java

示例15: buildUpdate

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void buildUpdate(String msg, int from) {
    db = new SQLiteDatabaseHandler(this);

    traitementNotif(msg, from);

    showdata = db.showAll();
    // on reinitialise avant de compter
    int CompteurLibrairies=0;
    int CompteurApplications=0;
    int CompteurBinaires=0;
    //lecture de la BDD pour la mise a jour de la vue
    for(SaveData save : showdata){
        if(save.getModule().equals("pm")){
            CompteurApplications++;
        }
        else if (save.getModule().equals("lib")){
            CompteurLibrairies++;
        }
        else if (save.getModule().equals("execve")){
            CompteurBinaires++;
        }
    }
    int total = CompteurBinaires + CompteurApplications + CompteurLibrairies;

    Log.i(TAG, "buildUpdate count app : " + CompteurApplications);
    Log.i(TAG, "buildUpdate count bin : " + CompteurBinaires);
    Log.i(TAG, "buildUpdate count lib : " + CompteurLibrairies);
    //Mise a jour de la vue
    RemoteViews view = new RemoteViews(getPackageName(), R.layout.activity_main);

    view.setTextViewText(R.id.event_count, "" + total);
    view.setTextViewText(R.id.last_event, last_event);
    if (last_event_level == 1){
        view.setInt(R.id.event_status, "setBackgroundResource", R.drawable.status_warn);
    }else if (last_event_level == 2){
        view.setInt(R.id.event_status, "setBackgroundResource", R.drawable.status_critic);
    }else if (last_event_level == 3){
        view.setInt(R.id.event_status, "setBackgroundResource", R.drawable.status_critic);
    }else if (last_event_level == 0){
        view.setInt(R.id.event_status, "setBackgroundResource", R.drawable.status_ok);
    }

    // Push update for this widget to the home screen
    ComponentName thisWidget = new ComponentName(this, MainActivity.class);
    AppWidgetManager manager = AppWidgetManager.getInstance(this);
    manager.updateAppWidget(thisWidget, view);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-dashboard,代码行数:48,代码来源:UpdateWidgetService.java


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