/**
   * Called when the BroadcastReceiver receives an Intent broadcast. Checks to see whether the
   * intent's action is _listClickAction. If it is, the app widget displays a Toast message for the
   * current item.
   */
  @Override
  public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(_listClickAction)) {
      // ---Launch video search in the browser---
      String searchText = intent.getStringExtra("search_text");
      String linkScheme1 = intent.getStringExtra("scheme1");
      String linkScheme2 = intent.getStringExtra("scheme2");
      Intent browserIntent = null; // new Intent(_listClickAction);
      try {
        browserIntent =
            new Intent(
                Intent.ACTION_VIEW,
                Uri.parse(linkScheme1 + URLEncoder.encode(searchText, "UTF-8") + linkScheme2));
      } catch (UnsupportedEncodingException e) {
        BugSenseHandler.sendExceptionMessage("Widget4x4Provider", "onReceive", e);
        Crashlytics.setString("Widget4x4Provider", "onReceive");
        Crashlytics.logException(e);

        if (ApplicationContext.DEBUG_MODE) e.printStackTrace();
      }

      browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      browserIntent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
      context.startActivity(browserIntent);
    } else if (intent.getAction().equals("android.appwidget.action.APPWIDGET_UPDATE")) {
      // ---Update the widget with latest search---
      final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
      onUpdate(context, mgr, appWidgetIds);
    }
    super.onReceive(context, intent);
  }
  @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);
  }
 /** 每当小部件添加或者更新时都会调用一次, 更新时机由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 onDisabled(Context context) {
   super.onDisabled(context);
   Log.d("Now Widget", "Widget Provider disabled. Turning off timer");
   AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
   alarmManager.cancel(createClockTickIntent(context));
 }
Exemple #5
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 onDeleted(Context context, int[] appWidgetIds) {
    // TODO Auto-generated method stub
    super.onDeleted(context, appWidgetIds);

    Toast.makeText(context, "Widget Silindi", Toast.LENGTH_SHORT).show();
  }
 @Override
 public void onReceive(@NonNull Context context, @NonNull Intent intent) {
   super.onReceive(context, intent);
   if (ACTION_REFRESH.equals(intent.getAction())) {
     handleRefreshAction(context, intent);
   }
 }
  @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);
  }
  @Override
  public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);

    if (CLOCK_WIDGET_UPDATE.equals(intent.getAction())) {

      Bundle extras = intent.getExtras();

      if (extras != null) {

        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        ComponentName thisAppWidget =
            new ComponentName(context.getPackageName(), VerboseClockWidget.class.getName());
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);

        onUpdate(context, appWidgetManager, appWidgetIds);
      }

    } else {
      Bundle extras = intent.getExtras();

      if (extras != null) {

        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        ComponentName thisAppWidget =
            new ComponentName(context.getPackageName(), VerboseClockWidget.class.getName());
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);

        onUpdate(context, appWidgetManager, appWidgetIds);
      }
    }
  }
  @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);
  }
 @Override
 public void onDisabled(Context context) {
   super.onDisabled(context);
   Log.i(AnkiDroidApp.TAG, "SmallWidget: Widget disabled");
   SharedPreferences preferences = PrefSettings.getSharedPrefs(context);
   preferences.edit().putBoolean("widgetSmallEnabled", false).commit();
 }
 @Override
 public void onDeleted(Context context, int[] appWidgetIds) {
   super.onDeleted(context, appWidgetIds);
   for (int widgetId : appWidgetIds) {
     deleteWidgetPrefs(context, widgetId);
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   // TODO Auto-generated method stub
   String action = intent.getAction();
   if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action) || action.equals(_myaction)) {
     int[] IDs = null;
     if (action.equals(_myaction)) {
       ComponentName provdier = new ComponentName(context, this.getClass());
       IDs = AppWidgetManager.getInstance(context).getAppWidgetIds(provdier);
     }
     Bundle extras = intent.getExtras();
     int[] appWidgetIds;
     if (extras != null || IDs != null) {
       if (extras != null) appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
       else appWidgetIds = IDs;
       if (appWidgetIds != null && appWidgetIds.length > 0) {
         if (appWidgetIds.length == 1) {
           this.onUpdate(context, AppWidgetManager.getInstance(context), appWidgetIds);
         } else if (appWidgetIds[0] < appWidgetIds[1]) {
           for (int i = 0; i < appWidgetIds.length; i++) {
             int[] tempappWidgetIds = {appWidgetIds[i]};
             this.onUpdate(context, AppWidgetManager.getInstance(context), tempappWidgetIds);
           }
         } else {
           for (int i = appWidgetIds.length - 1; i > -1; i--) {
             int[] tempappWidgetIds = {appWidgetIds[i]};
             this.onUpdate(context, AppWidgetManager.getInstance(context), tempappWidgetIds);
           }
         }
       }
     }
   } else {
     super.onReceive(context, intent);
   }
 }
Exemple #15
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);
  }
  @Override
  public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals("android.appwidget.action.notify")) {
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
      int appWidgetIds[] =
          appWidgetManager.getAppWidgetIds(new ComponentName(context, TimeTableProvider.class));

      for (int i = 0; i < appWidgetIds.length; i++) {
        Intent svcIntent = new Intent(context, TimeTableWidget.class);

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

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

        widget.setRemoteAdapter(appWidgetIds[i], R.id.words, svcIntent);

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

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

        widget.setTextViewText(R.id.weekday, TimeTableControl.today());
        appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
      }
      appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.words);
    }
    super.onReceive(context, intent);
  }
 @Override
 public void onDeleted(Context context, int[] appWidgetIds) {
   super.onDeleted(context, appWidgetIds);
   for (int appWidgetId : appWidgetIds) {
     PrefUtils.deleteWidget(context, appWidgetId);
   }
 }
  @Override
  public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    Utils.setContext(context);

    if (!LaunchManager.isWidgetEnabled()) {
      return;
    }

    if (intent.getAction() != null && intent.getAction().equals(ACTION_BUTTON_PRESS)) {

      if (WidgetManager.isWidgetTemporarilyVisible()) {
        // hide the widget again after tap
        WidgetManager.setWidgetTemporarilyVisible(false);
        updateMe(context);
      }

      long now = System.currentTimeMillis();
      long diff = now - mLastTime;

      if (diff < TOUCH_INTERVAL) {
        mClicks++;
      } else {
        mClicks = 1;
      }

      mLastTime = now;

      if (WidgetManager.getTapCountToOpen() == mClicks) {
        PinActivity.launch(context);
        mClicks = 0;
        mLastTime = 0;
      }
    }
  }
Exemple #19
0
 /** Each time an instance is removed, we cancel the associated AlarmManager. */
 @Override
 public void onDeleted(Context context, int[] widgetIds) {
   super.onDeleted(context, widgetIds);
   for (int widgetId : widgetIds) {
     cancelAlarm(context, widgetId);
   }
 }
  @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);
  }
  @Override
  public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);

    if (intent.getAction().equals(DATA_FETCHED)) {

      int appWidgetId =
          intent.getIntExtra(
              AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);

      RemoteViews remoteViews = updateWidgetListView(context, appWidgetId);

      // update and notify widget when data arrives

      appWidgetManager.updateAppWidget(appWidgetId, remoteViews);

      appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.stack_view);
    }

    if (intent.getAction().equals(TOAST_ACTION)) {
      // The click form the widget item is received here
      int appWidgetId =
          intent.getIntExtra(
              AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
      int viewIndex = intent.getIntExtra(EXTRA_ITEM, 0);
      context.startActivity(
          new Intent(context, ShowImagesActivity.class)
              .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
              .putExtra("click", "Clicked Movie is \n --- " + Constants.text[viewIndex]));
    }
  }
  @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);
  }
 @Override
 public void onReceive(Context context, Intent intent) {
   super.onReceive(context, intent);
   if (intent.getAction().equalsIgnoreCase("com.nure.sigma.wimk.wimk.WIDGET_CLICK")) {
     Intent i = new Intent(context.getApplicationContext(), SOSService.class);
     context.getApplicationContext().startService(i);
   }
 }
  @Override
  public void onDisabled(Context context) {

    Intent intent = new Intent(context.getApplicationContext(), UpdateWidgetService.class);
    context.stopService(intent);

    super.onDisabled(context);
  }
 @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);
  }
 @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);
 }
Exemple #28
0
 @Override
 public void onReceive(Context context, Intent intent) {
   super.onReceive(context, intent);
   if (CLICK_ACTION.equals(intent.getAction())) {
     Toast.show(
         context, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date()));
   }
 }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);

    for (int i : appWidgetIds) {
      updateAppWidget(context, appWidgetManager, i);
    }
  }
Exemple #30
0
 @SuppressLint("NewApi")
 @Override
 public void onAppWidgetOptionsChanged(
     final Context context, final AppWidgetManager manager, final int id, final Bundle options) {
   addView(manager, context, id, options);
   if (AppConstants.Versions.feature16Plus) {
     super.onAppWidgetOptionsChanged(context, manager, id, options);
   }
 }