List of usage examples for android.content Context NOTIFICATION_SERVICE
String NOTIFICATION_SERVICE
To view the source code for android.content Context NOTIFICATION_SERVICE.
Click Source Link
From source file:butter.droid.tv.service.recommendation.RecommendationBuilder.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public Notification build() throws IOException { if (VersionUtils.isLollipop()) { Log.d(TAG, "Building notification - " + this.toString()); if (mNotificationManager == null) { mNotificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); }//w w w . ja v a 2s.c o m Bundle extras = new Bundle(); if (mBackgroundUri != null) { extras.putString(Notification.EXTRA_BACKGROUND_IMAGE_URI, mBackgroundUri); } Bitmap image = Picasso.with(mContext).load(mImageUri) .resize((int) mContext.getResources().getDimension(R.dimen.card_width), (int) mContext.getResources().getDimension(R.dimen.card_height)) .get(); Notification notification = new NotificationCompat.BigPictureStyle( new NotificationCompat.Builder(mContext).setContentTitle(mTitle).setContentText(mDescription) .setPriority(mPriority).setLocalOnly(true).setOngoing(true) .setColor(mContext.getResources().getColor(R.color.primary)) .setCategory(Notification.CATEGORY_RECOMMENDATION).setLargeIcon(image) .setSmallIcon(mSmallIcon).setContentIntent(mIntent).setExtras(extras)).build(); mNotificationManager.notify(mId, notification); mNotificationManager = null; return notification; } return null; }
From source file:br.com.alquest.alquestdemo.app.Services.GcmIntentService.java
private void sendNotification(String type, String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); String title = ""; Log.e(TAG, type);//from w ww.ja v a2 s .c o m if (type.contains("message")) { title = getResources().getString(R.string.new_message); } PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); long[] pattern = { 500, 500, 500, 500, 500, 500, 500, 500, 500 }; NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setLights(0xFF0000FF, 100, 3000) .setVibrate(pattern).setSound(alarmSound).setSmallIcon(R.drawable.ic_launcher) .setContentTitle(title).setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) .setContentText(msg); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:android.demo.amitrai.gcmdemo.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./* w ww . ja va 2s .com*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, Splash.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.message).setContentTitle("GCM Message").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:br.com.interaje.turma2016_3.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from www .ja va 2 s . c o m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("GCM Message").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:br.com.bign.push.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w ww . j a v a 2s . c om */ private void sendNotification(String message, String title) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Random random = new Random(); notificationManager.notify(random.nextInt(), notificationBuilder.build()); }
From source file:com.trellmor.berrytube.BerryTube.java
@Override public void onCreate() { super.onCreate(); mNotificationManager = (NotificationManager) getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); }
From source file:MainActivity.java
@Deprecated public void showNotification(View view) { Intent activityIntent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, activityIntent, 0); Notification notification;// ww w .jav a2s. c om if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { notification = new Notification.Builder(this).setVisibility(Notification.VISIBILITY_PUBLIC) .setSmallIcon(Icon.createWithResource(this, R.mipmap.ic_launcher)) .addAction(new Notification.Action.Builder( Icon.createWithResource(this, android.R.drawable.ic_media_previous), "Previous", pendingIntent).build()) .addAction(new Notification.Action.Builder( Icon.createWithResource(this, android.R.drawable.ic_media_pause), "Pause", pendingIntent).build()) .addAction(new Notification.Action.Builder( Icon.createWithResource(this, android.R.drawable.ic_media_next), "Next", pendingIntent) .build()) .setContentTitle("Music").setContentText("Now playing...") .setLargeIcon(Icon.createWithResource(this, R.mipmap.ic_launcher)) .setStyle(new Notification.MediaStyle() //.setMediaSession(mMediaSession.getSessionToken()) .setShowActionsInCompactView(1)) .build(); } else { notification = new Notification.Builder(this).setVisibility(Notification.VISIBILITY_PUBLIC) .setSmallIcon(R.mipmap.ic_launcher) .addAction(new Notification.Action.Builder(android.R.drawable.ic_media_previous, "Previous", pendingIntent).build()) .addAction(new Notification.Action.Builder(android.R.drawable.ic_media_pause, "Pause", pendingIntent).build()) .addAction( new Notification.Action.Builder(android.R.drawable.ic_media_next, "Next", pendingIntent) .build()) .setContentTitle("Music").setContentText("Now playing...") .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .setStyle(new Notification.MediaStyle() //.setMediaSession(mMediaSession.getSessionToken()) .setShowActionsInCompactView(1)) .build(); } NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notification); }
From source file:MainActivity.java
private void showNotification() { Intent activityIntent = new Intent(this, MainActivity.class); activityIntent.setAction(ACTION_STOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, activityIntent, 0); final Builder notificationBuilder = new Builder(this).setContentTitle("Flashlight") .setContentText("Press to turn off the flashlight").setSmallIcon(R.mipmap.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .setContentIntent(pendingIntent).setVibrate(new long[] { DEFAULT_VIBRATE }) .setPriority(PRIORITY_MAX);//from ww w .j a v a2 s. co m NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }
From source file:asia.covisoft.goom.gcm.GoOmGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./* w w w .j a va 2 s . com*/ */ private void sendNotification(String title, String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:ca.hoogit.powerhour.Notifications.Foreground.java
public static void update(Context context, GameModel gameModel) { Notification notif = build(context, gameModel); NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(Constants.NOTIFICATION_ID.FOREGROUND_ID, notif); }