List of usage examples for android.media RingtoneManager getDefaultUri
public static Uri getDefaultUri(int type)
From source file:com.QuarkLabs.BTCeClient.MainActivity.java
@Override public void makeNotification(int id, String message) { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_bitcoin_sign) .setContentTitle(getResources().getString(R.string.app_name)).setContentText(message); mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(id, mBuilder.build()); }
From source file:com.firescar96.nom.GCMIntentService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void Notify(String notificationTitle, String notificationMessage, Bundle data, int id, boolean annoy) { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(thisService) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(notificationTitle) .setContentText(notificationMessage).setAutoCancel(true); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(thisService, MainActivity.class); resultIntent.putExtras(data);//from w ww . j av a2 s .c o m // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(thisService); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); if (annoy) { Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setSound(alarmSound); long[] pattern = { 50, 100, 10, 100, 10, 200 }; mBuilder.setVibrate(pattern); } NotificationManager mNotificationManager = (NotificationManager) thisService .getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(id, mBuilder.build()); }
From source file:com.touristadev.tourista.services.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///from w w w . jav a2s . co m public void sendNotification(String title, String messageBody, BookedPackage fbnot) { Intent intent2 = new Intent(getApplicationContext(), RequestActivity.class); intent2.putExtra("numberOfPerson", fbnot.getNumOfPeople()); intent2.putExtra("packageId", fbnot.getPackageId()); intent2.putExtra("reserveDate", fbnot.getReserveDate()); // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(RequestActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(intent2); PendingIntent contentIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_notification_marker).setContentTitle(title).setContentText(messageBody) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(contentIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.alivenet.dmvtaxi.FcmUtil.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./* www . j av a2 s . c om*/ */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void sendNotification(String message) { SharedPreference sharedPreference = new SharedPreference(); if (splitnotifiaction_flag) { intent = new Intent(this, AcceptNotificationUIwork.class); if (flag == true) { intent.putExtra("ridedriverInfo", MyApplication.rideDriverComplete); intent.putExtra("flag", flag); } } else { intent = new Intent(this, DeashboardActivity.class); if (flag == true) { intent.putExtra("ridedriverInfo", MyApplication.rideDriverComplete); intent.putExtra("flag", flag); } 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").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.unfc.choicecustomercare.gcmservices.MyGcmListenerService.java
private void sendNotificationForChargedNurse(String message) { Intent intent = new Intent(this, MainActivity.class); intent.setAction("chargedNurse"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Intent intentAccept = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingAccept = PendingIntent.getActivity(this, 1, intentAccept, PendingIntent.FLAG_ONE_SHOT); ///* w w w.j a v a 2 s. com*/ Intent intentDecline = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingDecline = PendingIntent.getActivity(this, 2, intentDecline, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(getString(R.string.app_name)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent).setAutoCancel(true); notificationBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; notificationBuilder.setAutoCancel(true); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify((int) new Date().getTime(), notificationBuilder.build()); }
From source file:com.zaparound.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///from w w w . j ava2 s . c om private void sendAcceptNotification(String messagetitle, String messageBody) { Intent intent = new Intent(this, LandingActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("CHATTAB_POSITION", 2); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); Notification notification = mBuilder.setSmallIcon(R.drawable.applogo).setTicker(messagetitle).setWhen(0) .setAutoCancel(true).setContentTitle(messagetitle) //.setNumber(++count) .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody)) //.setSubText("\n "+count+" new messages\n") .setContentIntent(pendingIntent) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.applogo)) .setContentText(messageBody).build(); NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notification); }
From source file:com.swetha.easypark.GetIndividualParkingSpotDetails.java
private Notification getNotification(String content) { Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle("EasyPark Notification"); builder.setContentText(content);// w w w . ja v a 2 s .c o m builder.setSmallIcon(R.drawable.ic_car); builder.setPriority(BIND_IMPORTANT); builder.setSound(soundUri); // return builder.build(); return new Notification.BigTextStyle(builder).bigText(content).build(); }
From source file:com.landenlabs.all_devtool.PackageFragment.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from ww w.j a v a 2 s .co m */ private void sendNotification(Context context, String from, String message) { /* Intent intent = new Intent(context, DevToolActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT); */ Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.shortcut_pkg).setContentTitle("Uninstalled").setContentText(message) .setAutoCancel(true); // .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }) // .setLights(Color.RED, 3000, 3000) // .setSound(defaultSoundUri) // .setSound(Settings.System.DEFAULT_NOTIFICATION_URI) // .setContentIntent(pendingIntent); // <uses-permission android:name="android.permission.VIBRATE" /> Notification note = notificationBuilder.build(); note.defaults |= Notification.DEFAULT_VIBRATE; note.defaults |= Notification.DEFAULT_SOUND; note.defaults |= Notification.DEFAULT_LIGHTS; NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, note); }
From source file:com.piggeh.palmettoscholars.services.MyFirebaseMessagingService.java
public void notifyNewsletter(String title, String URL) { Uri webpage = Uri.parse(URL); Intent contentIntent = new Intent(Intent.ACTION_VIEW, webpage); PendingIntent contentPendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, contentIntent, PendingIntent.FLAG_ONE_SHOT); Intent settingsIntent = new Intent(this, SettingsActivity.class); settingsIntent.putExtra("navigation_page", MainActivity.PAGE_SETTINGS); settingsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent settingsPendingIntent = PendingIntent.getActivity(this, 3 /* Request code */, settingsIntent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.BigTextStyle notifStyle = new NotificationCompat.BigTextStyle(); notifStyle.bigText(title);//from ww w. j a v a2 s. c o m notifStyle.setBigContentTitle(getString(R.string.notif_newsletter_title)); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon_nodpi) .setContentTitle(getString(R.string.notif_newsletter_title)).setContentText(title) .setAutoCancel(true).setSound(defaultSoundUri) .setColor(ContextCompat.getColor(this, R.color.colorPrimary)).setContentIntent(contentPendingIntent) .setStyle(notifStyle).addAction(R.drawable.ic_notifications_off, getString(R.string.notif_action_options), settingsPendingIntent); // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); // Build the notification and issues it with notification manager. notificationManager.notify(NOTIFICATION_ID_NEWSLETTER, notificationBuilder.build()); }
From source file:io.coldstart.android.GCMIntentService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void SendInboxStyleNotification(String alertCount, String alertTime, String hostname, String payloadDetails) {/*from ww w. j a va 2 s . c om*/ Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); String Line1 = "", Line2 = "", Line3 = "", Line4 = "", Line5 = ""; String[] separatedLines = payloadDetails.split("\n"); int payloadLength = separatedLines.length; if (payloadLength > 5) payloadLength = 5; for (int i = 0; i < payloadLength; i++) { try { switch (i) { case 0: { Line1 = separatedLines[i]; } break; case 1: { Line2 = separatedLines[i]; } break; case 2: { Line3 = separatedLines[i]; } break; case 3: { Line4 = separatedLines[i]; } break; case 4: { Line5 = separatedLines[i]; } break; } } catch (Exception e) { e.printStackTrace(); } } Notification notification = new Notification.InboxStyle( new Notification.Builder(this).setContentTitle("SNMP trap received") .setContentText(Line1 + " " + Line2 + "...").setSmallIcon(R.drawable.ic_stat_alert) .setVibrate(new long[] { 0, 100, 200, 300 }).setAutoCancel(true).setSound(uri) .setPriority(Notification.PRIORITY_MAX).setTicker("New SNMP traps have been received") .setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this, TrapListActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) .putExtra("forceRefresh", true), 0))).setBigContentTitle("New SNMP traps have been received") .setSummaryText("Launch ColdStart.io to Manage These Events").addLine(Line1) .addLine(Line2).addLine(Line3).addLine(Line4).build(); notification.defaults |= Notification.DEFAULT_SOUND; mNM.notify(43523, notification); }