List of usage examples for android.media RingtoneManager TYPE_NOTIFICATION
int TYPE_NOTIFICATION
To view the source code for android.media RingtoneManager TYPE_NOTIFICATION.
Click Source Link
From source file:com.example.jkgan.pmot.service.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w w w . ja va 2 s.c o m */ private void sendNotification(final String message, final String title, String id) { String url = MyApplication.getApiUrl() + "/promotions/" + id + "?token=" + MyApplication.getUser().getToken(); final Promotion[] promotion = { null }; final OkHttpClient client = new OkHttpClient(); final Request request = new Request.Builder().url(url).build(); // new Thread(new Runnable() { // @Override // public void run() { Response response = null; try { response = client.newCall(request).execute(); JSONObject jsnObj2 = new JSONObject(response.body().string()); promotion[0] = new Promotion(jsnObj2.optString("pName"), jsnObj2.optString("description"), jsnObj2.optString("id"), jsnObj2.getJSONObject("image").getJSONObject("medium").optString("url"), jsnObj2.getJSONObject("image").getJSONObject("small").optString("url"), jsnObj2.optString("term_and_condition"), jsnObj2.optString("name"), jsnObj2.optString("address"), jsnObj2.optString("sId"), getDate(jsnObj2.optString("starts_at")), getDate(jsnObj2.optString("expires_at")), jsnObj2.optString("phone")); Intent intent = new Intent(getApplicationContext(), PromotionActivity.class); intent.putExtra("NAME", promotion[0].getName()); intent.putExtra("SHOP_ID", promotion[0].getId()); intent.putExtra("IMAGE", promotion[0].getImage()); intent.putExtra("DESCRIPTION", promotion[0].getDescription()); intent.putExtra("TNC", promotion[0].getTnc()); intent.putExtra("SHOP_NAME", promotion[0].getShop().getName()); intent.putExtra("ADDRESS", promotion[0].getShop().getAddress()); intent.putExtra("START", promotion[0].getStarts_at()); intent.putExtra("EXPIRE", promotion[0].getExpires_at()); intent.putExtra("PHONE", promotion[0].getShop().getPhone()); intent.putExtra("SUBSCRIBED", true); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if (numMessages >= 1) { notificationTitle += (", " + title); notificationBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle((numMessages + 1) + " new promotions") .setContentText(notificationTitle).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); numMessages = 0; notificationBuilder.setContentText(message).setNumber(++numMessages); } else { notificationBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); notificationTitle = title; numMessages++; // notificationBuilder.setContentText(message) // .setNumber(++numMessages); } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // On gnre un nombre alatoire pour pouvoir afficher plusieurs notifications notificationManager.notify(notifyID, notificationBuilder.build()); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.gsma.rcs.ri.sharing.image.ImageSharingIntentService.java
/** * Add image share notification/*from w w w . j a v a 2 s . co m*/ * * @param invitation Intent invitation * @param ishDao the image sharing data object */ private void addImageSharingInvitationNotification(Intent invitation, ImageSharingDAO ishDao) { ContactId contact = ishDao.getContact(); if (contact == null) { if (LogUtils.isActive) { Log.e(LOGTAG, "addImageSharingInvitationNotification failed: cannot parse contact"); } return; } /* Create pending intent */ Intent intent = new Intent(invitation); intent.setClass(this, ReceiveImageSharing.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); /* * If the PendingIntent has the same operation, action, data, categories, components, and * flags it will be replaced. Invitation should be notified individually so we use a random * generator to provide a unique request code and reuse it for the notification. */ int uniqueId = Utils.getUniqueIdForPendingIntent(); PendingIntent contentIntent = PendingIntent.getActivity(this, uniqueId, intent, PendingIntent.FLAG_ONE_SHOT); String displayName = RcsContactUtil.getInstance(this).getDisplayName(contact); String title = getString(R.string.title_recv_image_sharing); /* Create notification */ NotificationCompat.Builder notif = new NotificationCompat.Builder(this); notif.setContentIntent(contentIntent); notif.setSmallIcon(R.drawable.ri_notif_csh_icon); notif.setWhen(System.currentTimeMillis()); notif.setAutoCancel(true); notif.setOnlyAlertOnce(true); notif.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); notif.setDefaults(Notification.DEFAULT_VIBRATE); notif.setContentTitle(title); notif.setContentText(getString(R.string.label_from_args, displayName)); /* Send notification */ NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(uniqueId, notif.build()); }
From source file:com.example.tacademy.miniproject.gcm.MyGcmListenerService.java
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").setTicker("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:com.survtapp.gcm.MyGcmListenerService.java
private Notification setBigPictureStyleNotification(String msg, String url, String title) { Bitmap remote_picture = null;// w w w . ja va 2s . co m // Create the style object with BigPictureStyle subclass. NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle(); notiStyle.setBigContentTitle(title); notiStyle.setSummaryText(msg); try { remote_picture = getBitmapFromURL(url); } catch (Exception e) { e.printStackTrace(); } notiStyle.bigPicture(remote_picture); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); return new NotificationCompat.Builder(this).setSmallIcon(R.drawable.survtapp_notification) .setColor(getResources().getColor(R.color.actionbar_color)).setAutoCancel(true) .setDefaults( Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.FLAG_SHOW_LIGHTS) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentIntent(resultPendingIntent).setContentTitle(title).setContentText(msg) .setStyle(notiStyle).build(); }
From source file:com.gsma.rcs.ri.sharing.video.VideoSharingIntentService.java
/** * Add video share notification// ww w. j av a 2 s.c o m * * @param invitation Intent invitation * @param vshDao the video sharing data object */ public void addVideoSharingInvitationNotification(Intent invitation, VideoSharingDAO vshDao) { if (vshDao.getContact() == null) { if (LogUtils.isActive) { Log.e(LOGTAG, "VideoSharingInvitationReceiver failed: cannot parse contact"); } return; } /* Create pending intent */ Intent intent = new Intent(invitation); intent.setClass(this, IncomingVideoSharing.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); /* * If the PendingIntent has the same operation, action, data, categories, components, and * flags it will be replaced. Invitation should be notified individually so we use a random * generator to provide a unique request code and reuse it for the notification. */ int uniqueId = Utils.getUniqueIdForPendingIntent(); PendingIntent contentIntent = PendingIntent.getActivity(this, uniqueId, intent, PendingIntent.FLAG_ONE_SHOT); String displayName = RcsContactUtil.getInstance(this).getDisplayName(vshDao.getContact()); String notifTitle = getString(R.string.title_recv_video_sharing); /* Create notification */ NotificationCompat.Builder notif = new NotificationCompat.Builder(this); notif.setContentIntent(contentIntent); notif.setSmallIcon(R.drawable.ri_notif_csh_icon); notif.setWhen(System.currentTimeMillis()); notif.setAutoCancel(true); notif.setOnlyAlertOnce(true); notif.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); notif.setDefaults(Notification.DEFAULT_VIBRATE); notif.setContentTitle(notifTitle); notif.setContentText(getString(R.string.label_from_args, displayName)); /* Send notification */ NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(uniqueId, notif.build()); }
From source file:com.app.infideap.postingapp.service.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. */// ww w .j a v a 2 s . c o m private void sendNotification(RemoteMessage remoteMessage) { // Toast.makeText(getApplication(), "Received", Toast.LENGTH_SHORT).show(); Notification notification = null; if (remoteMessage.getData() != null) notification = saveData(remoteMessage); else if (remoteMessage.getNotification() != null) notification = save(remoteMessage); if (notification == null) return; 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(notification.title) .setContentText(notification.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:com.hukum.app_framework.application.gcm.controller.AppGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param intent GCM message received.//from w w w . j av a 2s. c o m */ private void sendNotification(Intent intent, String message) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(getNotificationIcon()).setContentTitle(getString(R.string.app_name)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setPriority(Notification.PRIORITY_HIGH) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).setContentIntent(pendingIntent); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { notificationBuilder.setColor(getResources().getColor(R.color.color_accent)); } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }
From source file:com.pdmanager.firebase.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. */// w w w.ja v a2s . c o m private void sendNotification(String messageBody) { Intent intent = new Intent(this, ClinicianActivity.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("FCM Message").setContentText(messageBody).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.fast.van.cloudmessaging.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w . ja v a2 s . com*/ */ private void sendNotification(String orderId, String message, String notificationType) { /*Intent intent; if(notificationType!=null&¬ificationType.equals("DRIVER_ASSIGNED")){ intent=new Intent(this,ActivityNewRequest.class); }else{ }*/ if (BaseActivity.isForeGround()) { Intent intent = new Intent(this, ActivityNewRequest.class); intent.putExtra("message", message); intent.putExtra("orderId", orderId); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return; } BaseUtils.removeNotification(this); CommonData.saveNotificationData(this, orderId, message); Intent intent = new Intent(this, ActivitySplash.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("message", message); intent.putExtra("orderId", orderId); 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.notification).setContentTitle(getString(R.string.app_name)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(47 /* ID of notification */, notificationBuilder.build()); }
From source file:com.owncloud.android.jobs.NotificationJob.java
private void sendNotification(String contentTitle, Account account) { Context context = getContext(); Intent intent = new Intent(getContext(), NotificationsActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(KEY_NOTIFICATION_ACCOUNT, account.name); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.notification_icon) .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.notification_icon)) .setColor(ThemeUtils.primaryColor(context)).setShowWhen(true).setSubText(account.name) .setContentTitle(contentTitle) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)).setAutoCancel(true) .setContentIntent(pendingIntent); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_PUSH); }/*from ww w. j ava 2 s .c o m*/ NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }