Search in sources :

Example 11 with PendingIntent

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);
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 12 with PendingIntent

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);
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 13 with PendingIntent

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);
}
Also used : NotificationManager(android.app.NotificationManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 14 with PendingIntent

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);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 15 with PendingIntent

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());
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Aggregations

PendingIntent (android.app.PendingIntent)1208 Intent (android.content.Intent)1010 Notification (android.app.Notification)222 NotificationCompat (android.support.v4.app.NotificationCompat)167 AlarmManager (android.app.AlarmManager)149 NotificationManager (android.app.NotificationManager)148 Bundle (android.os.Bundle)75 RemoteViews (android.widget.RemoteViews)67 RemoteException (android.os.RemoteException)64 Resources (android.content.res.Resources)62 Bitmap (android.graphics.Bitmap)61 Context (android.content.Context)60 ComponentName (android.content.ComponentName)55 Test (org.junit.Test)44 Uri (android.net.Uri)42 IntentFilter (android.content.IntentFilter)41 SharedPreferences (android.content.SharedPreferences)36 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)33 UserHandle (android.os.UserHandle)31 ArrayList (java.util.ArrayList)30