List of usage examples for android.appwidget AppWidgetManager getInstance
public static AppWidgetManager getInstance(Context context)
From source file:de.domjos.schooltools.helper.Helper.java
public static void receiveBroadCast(Context context, Intent intent, int id) { Bundle bundle = intent.getExtras();//w w w . jav a2 s . co m if (bundle != null) { if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)) { int[] ids = bundle.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); appWidgetManager.notifyAppWidgetViewDataChanged(ids, id); } } }
From source file:me.kartikarora.transfersh.activities.TransferActivity.java
public void updateWidgets() { Intent intent = new Intent(TransferActivity.this, FilesAppWidgetProvider.class); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); AppWidgetManager widgetManager = AppWidgetManager.getInstance(getApplicationContext()); int[] ids = widgetManager .getAppWidgetIds(new ComponentName(getApplicationContext(), FilesAppWidgetProvider.class)); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); sendBroadcast(intent);/*from ww w . ja v a2 s .c o m*/ }
From source file:de.spiritcroc.modular_remote.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle(R.string.title_activity_main); Util.init(this); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); pages = new ArrayList<>(); String savedFragments = sharedPreferences.getString(getSavedFragmentsKey(), ""); if (DEBUG)//from w w w . jav a2s. c o m Log.v(LOG_TAG, "savedFragments: " + savedFragments); pagerTabStrip = (PagerTabStrip) findViewById(R.id.pager_tab_strip); viewPager = (CustomViewPager) findViewById(R.id.view_pager); forceOrientation = getIntent().getIntExtra(EXTRA_FORCE_ORIENTATION, -1); restoreContentFromRecreationKey(savedFragments); pages.get(0).setMenuEnabled(true); fragmentPagerAdapter = new CustomFragmentPagerAdapter(this, getFragmentManager()); viewPager.setAdapter(fragmentPagerAdapter); viewPager.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { boolean newY = Util.newY(viewPager); boolean newX = Util.newX(viewPager); if (newY || newX) { viewPager.post(new Runnable() { @Override public void run() { resizeContent(); } }); } } }); fullscreen = sharedPreferences.getBoolean(Preferences.FULLSCREEN, false); hideNavigationBar = sharedPreferences.getBoolean(Preferences.HIDE_NAVIGATION_BAR, false); hideActionBar = sharedPreferences.getBoolean(Preferences.HIDE_ACTION_BAR, false); decorView = getWindow().getDecorView(); decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int visibility) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { boolean visible = (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; if (visible) { delayedHide(); } } } }); appWidgetManager = AppWidgetManager.getInstance(this); appWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID); tcpConnectionManager = TcpConnectionManager.getInstance(getApplicationContext()); tcpConnectionManager.recreateConnectionsFromRecreationKey( sharedPreferences.getString(Preferences.SAVED_CONNECTIONS, "")); if (sharedPreferences.getInt(Preferences.SEEN_GREETING_VERSION, 0) < GreetingDialog.VERSION) { new GreetingDialog().show(getFragmentManager(), "GreetingDialog"); } else if (SetupGridSizeDialog.shouldShow(sharedPreferences)) { new SetupGridSizeDialog().show(getFragmentManager(), "SetupGridSizeDialog"); } getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); if (DEBUG) { getFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { Log.v(LOG_TAG, "Back stack count: " + getFragmentManager().getBackStackEntryCount()); } }); } if (getIntent().getBooleanExtra(EXTRA_RESTARTED_FROM_EDIT_MODE, false)) { enterEditMode(); } }
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); }/*from w ww .jav a 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); }//from w w w .ja v a2 s .c o m }
From source file:com.android.launcher3.widget.DigitalAppWidgetProvider.java
@Override public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {//from w w w . j a v a 2s . c o m // scale the fonts of the clock to fit inside the new size float ratio = WidgetUtils.getScaleRatio(context, newOptions, appWidgetId); AppWidgetManager widgetManager = AppWidgetManager.getInstance(context); updateClock(context, widgetManager, appWidgetId, ratio); }
From source file:com.miz.service.TheTVDB.java
private void updateWidgets() { AppWidgetManager awm = AppWidgetManager.getInstance(this); awm.notifyAppWidgetViewDataChanged(//ww w. jav a 2s . co m awm.getAppWidgetIds(new ComponentName(this, ShowStackWidgetProvider.class)), R.id.stack_view); // Update stack view widget awm.notifyAppWidgetViewDataChanged( awm.getAppWidgetIds(new ComponentName(this, ShowCoverWidgetProvider.class)), R.id.widget_grid); // Update grid view widget awm.notifyAppWidgetViewDataChanged( awm.getAppWidgetIds(new ComponentName(this, ShowBackdropWidgetProvider.class)), R.id.widget_grid); // Update grid view widget }
From source file:com.ferid.app.notetake.MainActivity.java
/** * Updates note widget//from www . ja v a2 s .c om */ private void updateNoteWidget() { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName thisAppWidget = new ComponentName(context.getPackageName(), this.getClass().getName()); Intent updateWidget = new Intent(context, NoteWidget.class); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget); updateWidget.setAction(NoteWidget.APP_TO_WID); updateWidget.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds); context.sendBroadcast(updateWidget); }
From source file:net.naonedbus.appwidget.HoraireWidgetProvider.java
/** * Grer le signal de rafraichissement.// ww w. j a va 2 s . c om */ @Override public void onReceive(final Context context, final Intent intent) { final String action = intent.getAction(); final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); if (DBG) Log.i(LOG_TAG, Integer.toHexString(hashCode()) + " - " + "onReceive " + action); final boolean updateWidget = ACTION_APPWIDGET_UPDATE.equals(action) || Intent.ACTION_USER_PRESENT.equals(action); if (updateWidget) { final int idExtra = intent.getIntExtra("id", -1); int[] ids; if (DBG) Log.i(LOG_TAG, Integer.toHexString(hashCode()) + " - " + "Rception de l'ordre de rafraichissement des widgets."); if (idExtra == -1) { ids = appWidgetManager.getAppWidgetIds(new ComponentName(context, this.getClass())); } else { ids = new int[] { idExtra }; } onUpdate(context, appWidgetManager, ids); } else if (HoraireWidgetProvider.ACTION_APPWIDGET_ON_CLICK.equals(action)) { final Arret arret = intent.getParcelableExtra("favori"); if (arret != null) { final ParamIntent startIntent = new ParamIntent(context, HorairesActivity.class); startIntent.putExtra(HorairesActivity.PARAM_ARRET, arret); startIntent.putExtra(HorairesActivity.PARAM_FROM_WIDGET, true); startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntentWithParentStack(startIntent); stackBuilder.startActivities(); } } super.onReceive(context, intent); }
From source file:org.gnucash.android.ui.homescreen.WidgetConfigurationActivity.java
/** * Updates all widgets belonging to the application * @param context Application context//from ww w . ja va 2 s. com */ public static void updateAllWidgets(final Context context) { Log.i("WidgetConfiguration", "Updating all widgets"); AppWidgetManager widgetManager = AppWidgetManager.getInstance(context); ComponentName componentName = new ComponentName(context, TransactionAppWidgetProvider.class); final int[] appWidgetIds = widgetManager.getAppWidgetIds(componentName); //update widgets asynchronously so as not to block method which called the update //inside the computation of the account balance new Thread(new Runnable() { @Override public void run() { for (final int widgetId : appWidgetIds) { updateWidget(context, widgetId); } } }).start(); }