Search in sources :

Example 81 with Notification

use of android.app.Notification in project robolectric by robolectric.

the class NotificationCompatBuilderTest method addAction__shouldAddActionToNotification.

@Test
public void addAction__shouldAddActionToNotification() {
    NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_corp_icon, "a title", null).build();
    Notification notification = new NotificationCompat.Builder(RuntimeEnvironment.application).addAction(action).build();
    assertThat(notification.actions).hasSize(1);
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification) Test(org.junit.Test)

Example 82 with Notification

use of android.app.Notification in project robolectric by robolectric.

the class ShadowServiceTest method startForeground.

@Test
public void startForeground() {
    Notification n = notBuilder.build();
    service.startForeground(23, n);
    assertThat(shadow.getLastForegroundNotification()).isSameAs(n);
    assertThat(shadow.getLastForegroundNotificationId()).isEqualTo(23);
    assertThat(nm.getNotification(23)).isSameAs(n);
    assertThat(n.flags & Notification.FLAG_FOREGROUND_SERVICE).isNotZero();
}
Also used : Notification(android.app.Notification) Test(org.junit.Test)

Example 83 with Notification

use of android.app.Notification in project robolectric by robolectric.

the class ShadowAccessibilityEventTest method shouldRecordParcelables.

@Test
public void shouldRecordParcelables() {
    final Notification notification = new Notification();
    event.setParcelableData(notification);
    AccessibilityEvent anotherEvent = AccessibilityEvent.obtain(event);
    assertThat(anotherEvent.getParcelableData() instanceof Notification).isEqualTo(true);
    assertThat(anotherEvent.getParcelableData()).isEqualTo(notification);
    anotherEvent.recycle();
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent) Notification(android.app.Notification) Test(org.junit.Test)

Example 84 with Notification

use of android.app.Notification in project mobile-android by photo.

the class NewPhotoObserver method showAutouploadIgnoredNotification.

/**
     * Show the autoupload ignored notification
     * 
     * @param file
     */
private void showAutouploadIgnoredNotification(File file) {
    NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    int icon = R.drawable.icon;
    long when = System.currentTimeMillis();
    String contentMessageTitle;
    contentMessageTitle = CommonUtils.getStringResource(R.string.upload_limit_reached_message);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
    Notification notification = builder.setContentTitle(CommonUtils.getStringResource(R.string.autoupload_ignored)).setContentText(contentMessageTitle).setWhen(when).setSmallIcon(icon).setAutoCancel(true).build();
    notificationManager.notify(file.hashCode(), notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification)

Example 85 with Notification

use of android.app.Notification 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)

Aggregations

Notification (android.app.Notification)568 PendingIntent (android.app.PendingIntent)276 Intent (android.content.Intent)253 NotificationManager (android.app.NotificationManager)128 StatusBarNotification (android.service.notification.StatusBarNotification)96 NotificationCompat (android.support.v4.app.NotificationCompat)64 Resources (android.content.res.Resources)56 Bitmap (android.graphics.Bitmap)48 Test (org.junit.Test)48 Context (android.content.Context)47 ITransientNotification (android.app.ITransientNotification)32 RemoteViews (android.widget.RemoteViews)30 RemoteException (android.os.RemoteException)24 ApplicationInfo (android.content.pm.ApplicationInfo)17 UserHandle (android.os.UserHandle)17 Date (java.util.Date)16 Uri (android.net.Uri)15 Bundle (android.os.Bundle)15 ComponentName (android.content.ComponentName)13 File (java.io.File)13