@DSVerified
  @DSBan(DSCat.DROIDSAFE_INTERNAL)
  public static void modelBroadCastReceiver(BroadcastReceiver receiver) {
    if (mApplication != null) {
      receiver.setApplication(mApplication);
      // callback receiver
      if (receiver instanceof android.app.admin.DeviceAdminReceiver) {
        DeviceAdminReceiver ar = (DeviceAdminReceiver) receiver;
        Intent appIntent = mApplication.droidsafeGetIntent();
        ar.onDisableRequested(context, appIntent);
        ar.onDisabled(context, appIntent);
        ar.onEnabled(context, appIntent);
        ar.onPasswordChanged(context, appIntent);
        ar.onPasswordExpiring(context, appIntent);
        ar.onPasswordFailed(context, appIntent);
        ar.onPasswordSucceeded(context, appIntent);
      }

      if (receiver instanceof android.appwidget.AppWidgetProvider) {
        AppWidgetProvider aw = (AppWidgetProvider) receiver;
        Intent appIntent = mApplication.droidsafeGetIntent();
        aw.onReceive(context, appIntent);
        aw.onEnabled(context);
        aw.onDisabled(context);
        int[] appWidgetIds = new int[1];
        appWidgetIds[0] = DSUtils.FAKE_INT;
        aw.onUpdate(context, AppWidgetManager.getInstance(context), appWidgetIds);
        aw.onDeleted(context, appWidgetIds);
      }
    }
  }
예제 #2
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.menu_layout);

    Intent update = new Intent(context, MenuProvider.class);
    update.setAction(CLICK_UPDATE);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, update_code, update, 0);
    remoteViews.setOnClickPendingIntent(R.id.update, pendingIntent);

    Intent nextDate = new Intent(context, MenuProvider.class);
    nextDate.setAction(CLICK_NEXT);
    pendingIntent = PendingIntent.getBroadcast(context, right_code, nextDate, 0);
    remoteViews.setOnClickPendingIntent(R.id.arrow_right, pendingIntent);

    Intent previousDate = new Intent(context, MenuProvider.class);
    previousDate.setAction(CLICK_PREVIOUS);
    pendingIntent = PendingIntent.getBroadcast(context, left_code, previousDate, 0);
    remoteViews.setOnClickPendingIntent(R.id.arrow_left, pendingIntent);

    remoteViews.setRemoteAdapter(R.id.dish_list, new Intent(context, DishListService.class));
    updateDate(remoteViews, R.id.date_text, PreferenceManager.getCalendar(context));
    appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
  }
예제 #3
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    for (int i = 0; i < appWidgetIds.length; i++) {
      // Setup the widget, and data source / adapter
      Intent svcIntent = new Intent(context, DDWidgetService.class);

      svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
      svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));

      RemoteViews widget;

      SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);

      if (sp.getString("theme", "Light").equals("Light")) {
        widget = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
      } else {
        widget = new RemoteViews(context.getPackageName(), R.layout.widget_layout_dark);
      }

      widget.setRemoteAdapter(R.id.listView, svcIntent);

      Intent clickIntent = new Intent(context, ClickHandlingActivity.class);
      PendingIntent clickPI =
          PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);

      widget.setPendingIntentTemplate(R.id.listView, clickPI);

      appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
예제 #4
0
 /** 每当小部件添加或者更新时都会调用一次, 更新时机由updatePeriodMillis决定 */
 @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   super.onUpdate(context, appWidgetManager, appWidgetIds);
   for (int appWidgetId : appWidgetIds) {
     onWidgetUpdate(context, appWidgetManager, appWidgetId);
   }
 }
  @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);
  }
예제 #6
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    for (int i = 0; i < appWidgetIds.length; i++) {
      GregorianCalendar cal = new GregorianCalendar();

      SimpleDateFormat weekFormat = new SimpleDateFormat("EEE");
      String strWeek = weekFormat.format(cal.getTime());

      SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM dd");
      String strDate = dateFormat.format(cal.getTime());

      RemoteViews remote = new RemoteViews(context.getPackageName(), R.layout.myapp_widget);
      remote.setTextViewText(R.id.tvDate, strDate);
      remote.setTextViewText(R.id.tvWeekDay, strWeek);

      Intent intent = new Intent(context, MyAppWidget.class);
      intent.setAction(ACTION_MYAPPWIDGET_DISPLAY);
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

      PendingIntent pIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
      remote.setOnClickPendingIntent(R.id.btnWidget, pIntent);

      appWidgetManager.updateAppWidget(appWidgetIds[i], remote);
    }
  }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    super.onUpdate(context, appWidgetManager, appWidgetIds);
    final int N = appWidgetIds.length;

    for (int i = 0; i < N; i++) {

      int widgetId = appWidgetIds[i];
      Intent intent = new Intent();
      intent.setAction(WidgetBroadcastReceiver.INTENT_ACTION);
      intent.putExtra("widgetID", widgetId);
      intent.setClassName(
          WidgetBroadcastReceiver.class.getPackage().getName(),
          WidgetBroadcastReceiver.class.getName());

      PendingIntent pendingIntent =
          PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

      remoteView = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
      remoteView.setOnClickPendingIntent(R.id.widgetButton, pendingIntent);

      appWidgetManager.updateAppWidget(widgetId, remoteView);
    }
  }
  @Override
  public void onUpdate(
      final Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    Log.d("TAG", "onUpdate");
    ComponentName thisWidget = new ComponentName(context, WeatherWidgetProvider.class);
    final int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
    WidgetManager widgetManager = new WidgetManager(context);
    widgetManager
        .fetchWeatherDataForWidget()
        .subscribeOn(Schedulers.newThread())
        .subscribe(
            new Subscriber<CityWeather>() {
              @Override
              public void onCompleted() {}

              @Override
              public void onError(Throwable e) {}

              @Override
              public void onNext(CityWeather cityWeather) {
                updateWeatherData(context, appWidgetManager, allWidgetIds, cityWeather);
              }
            });

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
예제 #9
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int appWidgetId : appWidgetIds) {
      Intent svcIntent = new Intent(context, WidgetService.class);

      svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
      svcIntent.putExtra(
          AppWidgetManager.EXTRA_CUSTOM_INFO, PrefUtils.getInt(appWidgetId + ".fontsize", 0));
      svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));

      RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.widget);
      widget.setOnClickPendingIntent(
          R.id.feed_icon,
          PendingIntent.getActivity(context, 0, new Intent(context, HomeActivity.class), 0));
      widget.setPendingIntentTemplate(
          R.id.feedsListView,
          PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW), 0));

      widget.setRemoteAdapter(R.id.feedsListView, svcIntent);
      widget.setInt(
          R.id.feedsListView,
          "setBackgroundColor",
          PrefUtils.getInt(appWidgetId + ".background", STANDARD_BACKGROUND));

      appWidgetManager.updateAppWidget(appWidgetId, widget);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
예제 #10
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    Log.d(TAG, "onUpdate");

    for (int i = 0; i < appWidgetIds.length; i++) {
      int appWidgetId = appWidgetIds[i];

      Intent intent = new Intent(context, StackWidgetService.class);
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);

      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

      RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
      views.setRemoteAdapter(appWidgetId, R.id.stack_view, intent);
      views.setEmptyView(R.id.stack_view, R.id.empty_view);

      Intent toastIntent = new Intent(context, FootballScoreWidget.class);
      toastIntent.setAction(FootballScoreWidget.OPEN_ACTIVITY_ACTION);
      toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      PendingIntent toastPendingIntent =
          PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      views.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

      appWidgetManager.updateAppWidget(appWidgetId, views);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    for (int i : appWidgetIds) {
      updateAppWidget(context, appWidgetManager, i);
    }
  }
예제 #12
0
 @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   for (int appWidgetId : appWidgetIds) {
     RemoteViews remoteViews = updateWidgetListView(context, appWidgetId);
     appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
   }
   super.onUpdate(context, appWidgetManager, appWidgetIds);
 }
예제 #13
0
 @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   super.onUpdate(context, appWidgetManager, appWidgetIds);
   RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.weather_widget);
   updateViews(context, views);
   ComponentName provider = new ComponentName(context, WeatherWidget.class);
   AppWidgetManager.getInstance(context).updateAppWidget(provider, views);
 }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    Intent i = new Intent();
    i.setClassName(VLC_PACKAGE, VLC_SERVICE);
    context.startService(i);
  }
예제 #15
0
파일: Helper.java 프로젝트: tgpraveen/Podax
  public static void updateWidgets(Context context) {
    AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);

    int[] widgetIds;

    widgetIds =
        widgetManager.getAppWidgetIds(new ComponentName(context, LargeWidgetProvider.class));
    if (widgetIds.length > 0) {
      AppWidgetProvider provider = (AppWidgetProvider) new LargeWidgetProvider();
      provider.onUpdate(context, widgetManager, widgetIds);
    }

    widgetIds =
        widgetManager.getAppWidgetIds(new ComponentName(context, SmallWidgetProvider.class));
    if (widgetIds.length > 0) {
      AppWidgetProvider provider = (AppWidgetProvider) new SmallWidgetProvider();
      provider.onUpdate(context, widgetManager, widgetIds);
    }
  }
예제 #16
0
  /** Update all widgets in the list */
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    ThemeManager.loadThemeProperties(context);

    for (int appWidgetId : appWidgetIds) {
      updateWidget(context, appWidgetId);
    }
  }
예제 #17
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    for (int appWidgetId : appWidgetIds) {
      updateAll(context, appWidgetId);
    }

    Util.addAlarmService(context, servicePendingIntent);
  }
예제 #18
0
 @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   // TODO Auto-generated method stub
   super.onUpdate(context, appWidgetManager, appWidgetIds);
   Intent intent = new Intent();
   intent.setClass(context, ShutterOffService.class);
   PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);
   RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
   remoteViews.setOnClickPendingIntent(R.id.btn_1, pendingIntent);
   appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
 }
 @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   super.onUpdate(context, appWidgetManager, appWidgetIds);
   // Loop through all widgets to display an update
   final int N = appWidgetIds.length;
   for (int i = 0; i < N; i++) {
     int appWidgetId = appWidgetIds[i];
     String titlePrefix = "Time since the widget was started: ";
     updateAppWidget(context, appWidgetManager, appWidgetId, titlePrefix);
   }
 }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    Log.d("Updating Room Widgets...");
    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int i = 0; i < appWidgetIds.length; i++) {
      int appWidgetId = appWidgetIds[i];
      RemoteViews remoteViews =
          new RemoteViews(
              context.getResources().getString(eu.power_switch.shared.R.string.PACKAGE_NAME),
              R.layout.widget_room);

      try {
        RoomWidget roomWidget = DatabaseHandler.getRoomWidget(appWidgetId);
        Room room = DatabaseHandler.getRoom(roomWidget.getRoomId());
        if (room != null) {
          Apartment apartment = DatabaseHandler.getApartment(room.getApartmentId());

          // update UI
          remoteViews.setTextViewText(
              R.id.textView_room_widget_name, apartment.getName() + ": " + room.getName());

          // set button action
          remoteViews.setOnClickPendingIntent(
              R.id.button_on,
              WidgetIntentReceiver.buildRoomWidgetButtonPendingIntent(
                  context,
                  apartment,
                  room,
                  context.getString(R.string.on),
                  ConfigureRoomWidgetActivity.ROOM_INTENT_ID_OFFSET + appWidgetId));
          remoteViews.setOnClickPendingIntent(
              R.id.button_off,
              WidgetIntentReceiver.buildRoomWidgetButtonPendingIntent(
                  context,
                  apartment,
                  room,
                  context.getString(R.string.off),
                  ConfigureRoomWidgetActivity.ROOM_INTENT_ID_OFFSET + appWidgetId + 1));
          remoteViews.setViewVisibility(R.id.linearlayout_room_widget, View.VISIBLE);
        } else {
          remoteViews.setTextViewText(
              R.id.textView_room_widget_name, context.getString(R.string.room_not_found));
          remoteViews.setViewVisibility(R.id.linearlayout_room_widget, View.GONE);
        }
      } catch (Exception e) {
        Log.e(e);
        remoteViews.setTextViewText(
            R.id.textView_room_widget_name, context.getString(R.string.unknown_error));
        remoteViews.setViewVisibility(R.id.linearlayout_room_widget, View.GONE);
      }
      appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
예제 #21
0
 @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   // TODO Auto-generated method stub
   // 显示时间的定时器,每秒刷新一次
   Timer timer = new Timer();
   timer.scheduleAtFixedRate(new MyTime(context, appWidgetManager), 1, 1000);
   // 显示天气的定时器,设置为没小时刷新一次
   Timer wTimer = new Timer();
   wTimer.scheduleAtFixedRate(new MyWeather(context, appWidgetManager), 1, 3600000);
   super.onUpdate(context, appWidgetManager, appWidgetIds);
 }
 /*
  * this method is called every 30 mins as specified on widgetinfo.xml
  * this method is also called on every phone reboot
  */
 @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   final int N = appWidgetIds.length;
   /*int[] appWidgetIds holds ids of multiple instance of your widget
    * meaning you are placing more than one widgets on your homescreen*/
   for (int i = 0; i < N; ++i) {
     initFlavorContact(context, appWidgetIds[i]);
     remoteViews = updateWidgetListView(context, appWidgetIds[i]);
     appWidgetManager.updateAppWidget(appWidgetIds[i], remoteViews);
   }
   super.onUpdate(context, appWidgetManager, appWidgetIds);
 }
예제 #23
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    try {
      ContextManager.setContext(context);
      super.onUpdate(context, appWidgetManager, appWidgetIds);

      // Start in service to prevent Application Not Responding timeout
      updateWidgets(context);
    } catch (Exception e) {
      Log.e("astrid-update-widget", "widget update error", e); // $NON-NLS-1$ //$NON-NLS-2$
    }
  }
예제 #24
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // Retrieve and format the current date and time
    String now = formatter.format(new Date());

    // Change the text in the widget
    RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget);
    updateViews.setTextViewText(R.id.text, now);
    appWidgetManager.updateAppWidget(appWidgetIds, updateViews);

    // Not really necessary, just a habit
    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    ComponentName thisWidget = new ComponentName(context, Widget4x4Provider.class);
    this.appWidgetIds = appWidgetIds;

    /*
    Set up the intent that starts the LargeWidgetService, which will
    provide the views for this collection.
    */
    Intent serviceIntent = new Intent(context, LargeWidgetService.class);

    // ---Add this app widget to the intent extras---
    serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, thisWidget);
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));

    /*
    This adapter connects to a RemoteViewsService through the specified intent.
    This is how you populate the data.
    */
    remoteView =
        new RemoteViews(
            context.getPackageName(), com.eazyigz.RussiaMediaSearch.R.layout.appwidget_4x4);
    //        remoteView.setRemoteAdapter(R.id.listViewWidget, serviceIntent);
    for (int i = 0; i < appWidgetManager.getAppWidgetIds(thisWidget).length; ++i) {
      remoteView.setRemoteAdapter(
          appWidgetManager.getAppWidgetIds(thisWidget)[i], R.id.listViewWidget, serviceIntent);
    }
    remoteView.setEmptyView(R.id.listViewWidget, R.id.row_empty_label_widget);

    final Intent onClickIntent = new Intent(context, Widget4x4Provider.class);
    onClickIntent.setAction(Widget4x4Provider._listClickAction);
    onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
    final PendingIntent listClickPendingIntent =
        PendingIntent.getBroadcast(context, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
      remoteView.setPendingIntentTemplate(R.id.listViewWidget, listClickPendingIntent);

    setupLauncherShortcut(context, remoteView);
    setupRussianVoiceSearch(context, remoteView);
    setupEnglishVoiceSearch(context, remoteView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
      appWidgetManager.notifyAppWidgetViewDataChanged(
          appWidgetManager.getAppWidgetIds(thisWidget), R.id.listViewWidget);
    appWidgetManager.updateAppWidget(thisWidget, remoteView);

    super.onUpdate(context, appWidgetManager, appWidgetManager.getAppWidgetIds(thisWidget));
  }
예제 #26
0
  @SuppressLint("NewApi")
  @Override
  public void onUpdate(final Context context, final AppWidgetManager manager, final int[] ids) {
    for (int id : ids) {
      final Bundle bundle;
      if (AppConstants.Versions.feature16Plus) {
        bundle = manager.getAppWidgetOptions(id);
      } else {
        bundle = null;
      }
      addView(manager, context, id, bundle);
    }

    super.onUpdate(context, manager, ids);
  }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    super.onUpdate(context, appWidgetManager, appWidgetIds);

    final int N = appWidgetIds.length;

    // Perform this loop procedure for each App Widget that belongs to this
    // provider
    for (int i = 0; i < N; i++) {
      int appWidgetId = appWidgetIds[i];

      updateAppWidget(context, appWidgetManager, appWidgetId);
    }
  }
예제 #28
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);

    Intent intent = new Intent(context, LoginScreen.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
    remoteViews.setOnClickPendingIntent(R.id.widget_launchbutton, pendingIntent);
    intent = new Intent(context, AddTask.class);
    pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
    remoteViews.setOnClickPendingIntent(R.id.widget_addbutton, pendingIntent);

    updateWidgetContent(context, appWidgetManager, appWidgetIds, remoteViews);
  }
 @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   // There may be multiple widgets active, so update all of them
   for (int appWidgetId : appWidgetIds) {
     RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_arrivals);
     // Set up the collection
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
       setRemoteAdapter(context, views);
     } else {
       setRemoteAdapterV11(context, views);
     }
     views.setEmptyView(R.id.widget_list, R.id.widget_empty);
     appWidgetManager.updateAppWidget(appWidgetId, views);
   }
   super.onUpdate(context, appWidgetManager, appWidgetIds);
 }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    if (Constants.debugModeWidget) Log.d(TAG, "onUpdate");

    // update each of the app widgets with the remote adapter
    for (int appWidgetId : appWidgetIds) {
      updateAppWidget(context, appWidgetManager, appWidgetId);
      // appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list_view);

      if (Constants.debugModeWidget) Log.d(TAG, "UPDATE WIDGET - WIDGET_ID: " + appWidgetId);
    }

    // int appWidgetIds[] = appWidgetManager.getAppWidgetIds(new ComponentName(context,
    // WidgetProvider.class));

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }