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);
}
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();
}
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();
}
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);
}
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;
}
Aggregations