List of usage examples for android.appwidget AppWidgetManager ACTION_APPWIDGET_UPDATE
String ACTION_APPWIDGET_UPDATE
To view the source code for android.appwidget AppWidgetManager ACTION_APPWIDGET_UPDATE.
Click Source Link
From source file:org.kiwix.kiwixmobile.KiwixMobileActivity.java
public static void updateWidgets(Context context) { Intent intent = new Intent(context.getApplicationContext(), KiwixSearchWidget.class); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); // Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID, // since it seems the onUpdate() is only fired on that: AppWidgetManager widgetManager = AppWidgetManager.getInstance(context); int[] ids = widgetManager.getAppWidgetIds(new ComponentName(context, KiwixSearchWidget.class)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { widgetManager.notifyAppWidgetViewDataChanged(ids, android.R.id.list); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); context.sendBroadcast(intent);//from w ww . ja v a2s.c o m } }
From source file:com.xperia64.timidityae.MusicService.java
public void stop() { if (Globals.isPlaying == 0) { death = true;//from w w w. j a va2 s . co m Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.ta_rec)); new_intent.putExtra(getResources().getString(R.string.ta_cmd), 5); new_intent.putExtra(getResources().getString(R.string.ta_pause), false); sendBroadcast(new_intent); Globals.shouldRestore = false; JNIHandler.stop(); if (fullStop) { TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); if (mgr != null) { mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); } Globals.shouldRestore = false; if (wl.isHeld()) wl.release(); foreground = false; fullStop = false; // Fix the widget if (shouldDoWidget) { new_intent = new Intent(this, TimidityAEWidgetProvider.class); new_intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); //new_intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); new_intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); new_intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.paused", true); new_intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.title", ""); new_intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.onlyart", false); new_intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.death", true); sendBroadcast(new_intent); } else { Globals.nukedWidgets = true; } stopForeground(true); //stopSelf(); } } }
From source file:com.xperia64.timidityae.MusicService.java
public void updateNotification(String title, boolean paused) { //System.out.println("Updating notification"); remoteViews = new RemoteViews(getPackageName(), R.layout.music_notification); remoteViews.setTextViewText(R.id.titley, currTitle); remoteViews.setImageViewResource(R.id.notPause, (paused) ? R.drawable.ic_media_play : R.drawable.ic_media_pause); // Previous// w w w. j a va 2 s . c o m Intent new_intent = new Intent(); //new_intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 4); PendingIntent pendingNotificationIntent = PendingIntent.getBroadcast(this, 1, new_intent, 0); remoteViews.setOnClickPendingIntent(R.id.notPrev, pendingNotificationIntent); // Play/Pause new_intent = new Intent(); //new_intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 2); pendingNotificationIntent = PendingIntent.getBroadcast(this, 2, new_intent, 0); remoteViews.setOnClickPendingIntent(R.id.notPause, pendingNotificationIntent); // Next new_intent = new Intent(); //new_intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 3); pendingNotificationIntent = PendingIntent.getBroadcast(this, 3, new_intent, 0); remoteViews.setOnClickPendingIntent(R.id.notNext, pendingNotificationIntent); // Stop new_intent = new Intent(); //new_intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 5); pendingNotificationIntent = PendingIntent.getBroadcast(this, 4, new_intent, 0); remoteViews.setOnClickPendingIntent(R.id.notStop, pendingNotificationIntent); final Intent emptyIntent = new Intent(this, TimidityActivity.class); //emptyIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); PendingIntent pendingIntent = PendingIntent.getActivity(this, 5, emptyIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setContentTitle(getResources().getString(R.string.app_name)).setContentText(currTitle) .setContentIntent(pendingIntent).setContent(remoteViews); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mBuilder.setSmallIcon(R.drawable.ic_lol); else mBuilder.setSmallIcon(R.drawable.ic_launcher); n = mBuilder.build(); n.flags |= Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_ONGOING_EVENT; if (!foreground) { foreground = true; startForeground(13901858, n); if (!wl.isHeld()) wl.acquire(); TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); if (mgr != null) { mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); } } else { if (!wl.isHeld()) wl.acquire(); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(13901858, n); } if (shouldDoWidget) { Intent intent = new Intent(this, TimidityAEWidgetProvider.class); //Intent intent = new Intent("Ilikepotatoes"); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); // Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID, // since it seems the onUpdate() is only fired on that: //intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.paused", paused); intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.title", currTitle); intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.onlyart", true); sendBroadcast(intent); } }
From source file:com.homeworkreminder.Main.java
public static void updateAppWidget() { Intent intent = new Intent(context, Widget.class); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); // Use an array and EXTRA_APPWIDGET_IDS instead of // AppWidgetManager.EXTRA_APPWIDGET_ID, // since it seems the onUpdate() is only fired on that: int ids[] = AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, Widget.class)); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); context.sendBroadcast(intent);// ww w . j a v a 2s . c o m }