Search in sources :

Example 21 with PendingIntent

use of android.app.PendingIntent in project cw-android by commonsguy.

the class NotifyDemo method notifyMe.

public void notifyMe(View v) {
    Notification note = new Notification(R.drawable.stat_notify_chat, "Status message!", System.currentTimeMillis());
    PendingIntent i = PendingIntent.getActivity(this, 0, new Intent(this, NotifyMessage.class), 0);
    note.setLatestEventInfo(this, "Notification Title", "This is the notification message", i);
    note.number = ++count;
    note.vibrate = new long[] { 500L, 200L, 200L, 500L };
    note.flags |= Notification.FLAG_AUTO_CANCEL;
    mgr.notify(NOTIFY_ME_ID, note);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 22 with PendingIntent

use of android.app.PendingIntent in project AnimeTaste by daimajia.

the class MissionListenerForNotification method onSuccess.

//todo:修复
@Override
public void onSuccess(M3U8Mission mission) {
    Intent intent = new Intent(context, PlayActivity.class);
    Animation animation = (Animation) mission.getExtraInformation(mission.getUri());
    intent.putExtra("Animation", animation);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
    notifyBuilder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_action_emo_wink).setContentTitle(mission.getShowName()).setContentText(context.getString(R.string.download_success)).setProgress(100, mission.getPercentage(), false).setContentIntent(pendingIntent).setOngoing(false);
    notificationManager.notify(mission.getMissionID(), notifyBuilder.build());
    MobclickAgent.onEvent(context, "download_success");
}
Also used : Animation(com.zhan_dui.model.Animation) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 23 with PendingIntent

use of android.app.PendingIntent in project android-gcm by chiuki.

the class GCMIntentService method prepareNotification.

private Notification prepareNotification(Context context, String msg) {
    long when = System.currentTimeMillis();
    Notification notification = new Notification(R.drawable.ic_stat_cloud, msg, when);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    Intent intent = new Intent(context, MessageActivity.class);
    // Set a unique data uri for each notification to make sure the activity
    // gets updated
    intent.setData(Uri.parse(msg));
    intent.putExtra(Constants.FIELD_MESSAGE, msg);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
    String title = context.getString(R.string.app_name);
    notification.setLatestEventInfo(context, title, msg, pendingIntent);
    return notification;
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 24 with PendingIntent

use of android.app.PendingIntent in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent i = new Intent(this, VoiceReceiver.class);
    PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
    RemoteInput remoteInput = new RemoteInput.Builder(VoiceReceiver.EXTRA_SPEECH).setLabel(getString(R.string.talk)).setChoices(getResources().getStringArray(R.array.replies)).build();
    NotificationCompat.Action wearAction = new NotificationCompat.Action.Builder(android.R.drawable.ic_btn_speak_now, getString(R.string.talk), pi).addRemoteInput(remoteInput).build();
    NotificationCompat.WearableExtender wearExtender = new NotificationCompat.WearableExtender().addAction(wearAction);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(android.R.drawable.stat_sys_download_done).setContentTitle(getString(R.string.title)).setContentText(getString(R.string.talk)).extend(wearExtender);
    NotificationManagerCompat.from(this).notify(NOTIFY_ID, builder.build());
    finish();
}
Also used : RemoteInput(android.support.v4.app.RemoteInput) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 25 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);
    Thingy thingy = new Thingy(mgr.getClass().getCanonicalName(), mgr.hashCode());
    Intent i = new Intent(ctxt, PollReceiver.class).putExtra(EXTRA_THINGY, Parcelables.toByteArray(thingy));
    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)

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