List of usage examples for android.appwidget AppWidgetManager getAppWidgetIds
public int[] getAppWidgetIds(ComponentName provider)
From source file:com.meiste.greg.ptw.WidgetProvider.java
private int[] getInstalledWidgets(final Context context) { final ComponentName thisWidget = new ComponentName(context, WidgetProvider.class); final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); return appWidgetManager.getAppWidgetIds(thisWidget); }
From source file:ru.kaefik.isaifutdinov.an_weather_widget.AnWeatherWidget.java
@Override public void onReceive(Context context, Intent intent) { Log.i(TAG_SERVICE, " onReceive " + intent.getAction()); super.onReceive(context, intent); if (FORCE_WIDGET_UPDATE.equals(intent.getAction())) { String nameCity = intent.getStringExtra(PARAM_CITY); String tempCity = intent.getStringExtra(PARAM_TEMP); String windCity = intent.getStringExtra(PARAM_WIND); String timeRefreshCity = intent.getStringExtra(PARAM_TIMEREFRESH); String weatherImageCity = intent.getStringExtra(PARAM_WEATHERIMAGE); String descriptionWeather = intent.getStringExtra(PARAM_DESCWEATHER); int WidgetId = intent.getIntExtra(PARAM_WIDGETID, 0); //TODO: ? , ?. ? ? GetWeatherCityService Log.i(TAG_SERVICE, "onReceive " + nameCity + " -> " + tempCity); // //from w ww .jav a 2 s . c o m AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName thisWidget = new ComponentName(context, AnWeatherWidget.class); int[] appWidgetId = appWidgetManager.getAppWidgetIds(thisWidget); for (int i = 0; i < appWidgetId.length; i++) { Log.i(TAG_SERVICE, "onReceive -> appWidgetId = " + String.valueOf(appWidgetId[i])); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.an_weather_widget); if (WidgetId == appWidgetId[i]) { views.setTextViewText(R.id.cityNameText, nameCity); views.setTextViewText(R.id.tempCityText, tempCity); views.setTextViewText(R.id.windText, windCity); views.setTextViewText(R.id.timeRefreshText, timeRefreshCity); views.setTextViewText(R.id.descriptionWeatherText, descriptionWeather); views.setImageViewUri(R.id.weatherImageView, Uri.parse("android.resource://ru.kaefik.isaifutdinov.an_weather_widget/mipmap/" + "weather" + weatherImageCity)); // ? CLICK_WIDGET_BUTTON onReceive // Intent ? Broadcast Intent active = new Intent(context, AnWeatherWidget.class); active.setAction(CLICK_WIDGET_BUTTON); //? ? PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0); //? ? views.setOnClickPendingIntent(R.id.refreshButton, actionPendingIntent); //? // END - ? CLICK_WIDGET_BUTTON onReceive appWidgetManager.updateAppWidget(appWidgetId[i], views); break; } appWidgetManager.updateAppWidget(appWidgetId[i], views); } } if (CLICK_WIDGET_BUTTON.equals(intent.getAction())) { Log.i(TAG_SERVICE, " "); // AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName thisWidget = new ComponentName(context, AnWeatherWidget.class); int[] appWidgetId = appWidgetManager.getAppWidgetIds(thisWidget); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.an_weather_widget); // ? for (int i = 0; i < appWidgetId.length; i++) { Log.i(TAG_SERVICE, "id -> " + String.valueOf(appWidgetId[i])); String nameCity = ConfigActivity.loadStringParametersFromFile(context, String.valueOf(appWidgetId[i])); startGetWeatherCityService(context, appWidgetId[i], new CityModel(nameCity)); } } }
From source file:com.dpcsoftware.mn.App.java
public void setFlag(int tableId) { switch (tableId) { case 1:/*from w ww . jav a 2 s . c om*/ mnUpdateList = true; //Update widgets if anyone is being used AppWidgetManager wManager = AppWidgetManager.getInstance(this); ComponentName cWidgetProvider = new ComponentName(this, Widget1.class); int wIds[] = wManager.getAppWidgetIds(cWidgetProvider); if (wIds.length != 0) { Intent updateIntent = new Intent(this, Widget1.class); updateIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, wIds); try { PendingIntent.getBroadcast(this, 0, updateIntent, PendingIntent.FLAG_UPDATE_CURRENT).send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } } break; case 2: mnUpdateList = true; break; case 3: mnUpdateMenu = true; break; } }
From source file:de.hero.vertretungsplan.MainActivity.java
@SuppressLint("NewApi") public void updateWidget() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { AppWidgetManager appManager = AppWidgetManager.getInstance(this); ComponentName name = new ComponentName(this, WidgetProvider.class); appManager.notifyAppWidgetViewDataChanged(appManager.getAppWidgetIds(name), R.id.words); }/*from w ww . j a va 2 s .c o m*/ }
From source file:org.cowboycoders.cyclisimo.widgets.TrackWidgetProvider.java
@Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); String action = intent.getAction(); if (context.getString(R.string.track_paused_broadcast_action).equals(action) || context.getString(R.string.track_resumed_broadcast_action).equals(action) || context.getString(R.string.track_started_broadcast_action).equals(action) || context.getString(R.string.track_stopped_broadcast_action).equals(action) || context.getString(R.string.track_update_broadcast_action).equals(action)) { long trackId = intent.getLongExtra(context.getString(R.string.track_id_broadcast_extra), -1L); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIds = appWidgetManager .getAppWidgetIds(new ComponentName(context, TrackWidgetProvider.class)); for (int appWidgetId : appWidgetIds) { RemoteViews remoteViews = getRemoteViews(context, trackId, HEIGHT_SIZE.get(appWidgetId, DEFAULT_SIZE)); appWidgetManager.updateAppWidget(appWidgetId, remoteViews); }/*from w w w . j a va 2 s . c o m*/ } }
From source file:com.kubotaku.android.code4kyoto5374.fragments.HomeSelectFragment.java
private void updateAppWidget() { Context context = getContext(); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName componentName = new ComponentName(context, GarbageCollectDayWidget.class); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetManager.getAppWidgetIds(componentName), R.id.list_collect_days);/*from w w w . j a va 2 s .co m*/ }
From source file:nl.mpcjanssen.simpletask.TodoApplication.java
public void updateWidgets() { AppWidgetManager mgr = AppWidgetManager.getInstance(getApplicationContext()); for (int appWidgetId : mgr .getAppWidgetIds(new ComponentName(getApplicationContext(), MyAppWidgetProvider.class))) { mgr.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widgetlv); Log.v(TAG, "Updating widget: " + appWidgetId); }// w w w . java 2 s .c o m }
From source file:nl.mpcjanssen.simpletask.TodoApplication.java
private void redrawWidgets() { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext()); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(this, MyAppWidgetProvider.class)); Log.v(TAG, "Redrawing widgets "); if (appWidgetIds.length > 0) { new MyAppWidgetProvider().onUpdate(this, appWidgetManager, appWidgetIds); }// w ww.j a v a2 s .c o m }
From source file:com.daskiworks.ghwatch.backend.UnreadNotificationsService.java
protected void updateWidgets() { if (PreferencesUtils.getBoolean(context, PreferencesUtils.PREF_WIDGET_UNREAD_EXISTS, false)) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] ids = appWidgetManager.getAppWidgetIds(new ComponentName(context, UnreadAppWidgetProvider.class)); Intent intent = new Intent(context, UnreadAppWidgetProvider.class); intent.setAction("android.appwidget.action.APPWIDGET_UPDATE"); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); context.sendBroadcast(intent);/*ww w. ja v a 2s.c o m*/ Log.d(TAG, "Widget update Intent fired"); } }
From source file:com.ferid.app.cleaner.MainActivity.java
/** * Update cleaner widget//from ww w . j a v a 2 s . c o m */ private void updateCleanerWidget() { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName thisAppWidget = new ComponentName(context.getPackageName(), this.getClass().getName()); Intent updateWidget = new Intent(context, CleanerWidget.class); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget); updateWidget.setAction(CleanerWidget.APP_TO_WID); updateWidget.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds); context.sendBroadcast(updateWidget); }