Java Code Examples for android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE
The following examples show how to use
android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WidgetConfigure.java From writeily-pro with MIT License | 5 votes |
public final void complete(String directory) { Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); Context context = getApplicationContext(); // Store widget filter SharedPreferences preferences = context.getSharedPreferences("" + mAppWidgetId, MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putString(Constants.WIDGET_PATH, directory); editor.apply(); Intent resultValue = new Intent(context, FilesWidgetService.class); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); setResult(RESULT_OK, resultValue); Intent i = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, this, WriteilyWidgetProvider.class); i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{mAppWidgetId}); sendBroadcast(i); finish(); } }
Example 2
Source File: ControlWidget.java From BlueSound with The Unlicense | 4 votes |
public static void requestWidgetUpdate(Context context ){ Intent brIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); context.getApplicationContext().sendBroadcast(brIntent); }
Example 3
Source File: EarthAppWidgetProvider.java From earth with GNU General Public License v3.0 | 4 votes |
public static void triggerUpdate(Context context) { final Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, getAppWidgetIds(context)); context.sendBroadcast(intent); }
Example 4
Source File: WidgetProvider.java From Simple-Dilbert with Apache License 2.0 | 4 votes |
@Override public void onReceive(@NotNull Context context, @NotNull Intent intent) { String action = intent.getAction(); if (intent.getExtras() == null) return; final int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); final DilbertPreferences preferences = new DilbertPreferences(context); if (action == null || appWidgetId == -1) { super.onReceive(context, intent); return; } if (currentToast != null) currentToast.cancel(); switch (action) { case INTENT_PREVIOUS: preferences.saveDateForWidgetId(appWidgetId, preferences .getDateForWidgetId(appWidgetId).minusDays(1)); break; case INTENT_NEXT: preferences.saveDateForWidgetId(appWidgetId, preferences .getDateForWidgetId(appWidgetId).plusDays(1)); break; case INTENT_LATEST: preferences.saveDateForWidgetId(appWidgetId, LocalDate.now()); break; case INTENT_RANDOM: preferences.saveDateForWidgetId(appWidgetId, DilbertPreferences.getRandomDate()); break; case INTENT_REFRESH: preferences .removeCache(preferences.getDateForWidgetId(appWidgetId)); break; case INTENT_DISPLAY: preferences.saveCurrentDate(preferences .getDateForWidgetId(appWidgetId)); Intent display = new Intent(context, DilbertFragmentActivity.class); display.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(display); break; case AppWidgetManager.ACTION_APPWIDGET_UPDATE: LocalDate current = preferences.getDateForWidgetId(appWidgetId); if (current.equals(LocalDate.now() .minusDays(1))) { preferences.saveDateForWidgetId(appWidgetId, LocalDate.now()); } break; } updateAppWidget(context, AppWidgetManager.getInstance(context), appWidgetId); if (currentToast != null) currentToast.show(); super.onReceive(context, intent); }