use of android.app.PendingIntent in project cw-advandroid by commonsguy.
the class WidgetProvider method onUpdate.
@Override
public void onUpdate(Context ctxt, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int i = 0; i < appWidgetIds.length; i++) {
Intent svcIntent = new Intent(ctxt, WidgetService.class);
svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews widget = new RemoteViews(ctxt.getPackageName(), R.layout.widget);
widget.setRemoteAdapter(appWidgetIds[i], R.id.words, svcIntent);
Intent clickIntent = new Intent(ctxt, LoremActivity.class);
PendingIntent clickPI = PendingIntent.getActivity(ctxt, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
widget.setPendingIntentTemplate(R.id.words, clickPI);
appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
}
super.onUpdate(ctxt, appWidgetManager, appWidgetIds);
}
use of android.app.PendingIntent in project cw-advandroid by commonsguy.
the class AppWidget method buildUpdate.
private RemoteViews buildUpdate(Context ctxt, int[] appWidgetIds) {
RemoteViews updateViews = new RemoteViews(ctxt.getPackageName(), R.layout.widget);
Intent i = new Intent(ctxt, AppWidget.class);
i.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
updateViews.setImageViewResource(R.id.left_die, IMAGES[(int) (Math.random() * 6)]);
updateViews.setOnClickPendingIntent(R.id.left_die, pi);
updateViews.setImageViewResource(R.id.right_die, IMAGES[(int) (Math.random() * 6)]);
updateViews.setOnClickPendingIntent(R.id.right_die, pi);
updateViews.setOnClickPendingIntent(R.id.background, pi);
return (updateViews);
}
use of android.app.PendingIntent in project cw-advandroid by commonsguy.
the class NoticeReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
NotificationManager mgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification note = new Notification(R.drawable.stat_notify_chat, "Yoo-hoo! Wake up!", System.currentTimeMillis());
PendingIntent i = PendingIntent.getActivity(context, 0, new Intent(context, OrderedActivity.class), 0);
note.setLatestEventInfo(context, "You Care About This!", "...but not enough to keep the activity running", i);
mgr.notify(NOTIFY_ME_ID, note);
}
use of android.app.PendingIntent in project cw-omnibus by commonsguy.
the class PollReceiver method scheduleAlarms.
static void scheduleAlarms(Context ctxt) {
AlarmManager mgr = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(ctxt, PollReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, 0);
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + INITIAL_DELAY, PERIOD, pi);
}
use of android.app.PendingIntent in project cw-omnibus by commonsguy.
the class WebServerService method foregroundify.
private void foregroundify() {
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
Intent iReceiver = new Intent(this, StopReceiver.class);
PendingIntent piReceiver = PendingIntent.getBroadcast(this, 0, iReceiver, 0);
b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL);
buildForegroundNotification(b);
b.addAction(R.drawable.ic_stop_white_24dp, getString(R.string.notify_stop), piReceiver);
startForeground(NOTIFY_ID, b.build());
}
Aggregations