Example usage for android.media RingtoneManager TYPE_NOTIFICATION

List of usage examples for android.media RingtoneManager TYPE_NOTIFICATION

Introduction

In this page you can find the example usage for android.media RingtoneManager TYPE_NOTIFICATION.

Prototype

int TYPE_NOTIFICATION

To view the source code for android.media RingtoneManager TYPE_NOTIFICATION.

Click Source Link

Document

Type that refers to sounds that are used for notifications.

Usage

From source file:com.tring.urloop.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 *///from  w w w. j  av a  2  s  .co m
private void sendNotification(String messageBody) {
    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)
            .setContentTitle("FCM Message").setSmallIcon(R.mipmap.ic_launcher).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:ar.fi.uba.jobify.service.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 *//*w ww. ja va 2 s .c  o m*/
private void sendNotification(String messageBody) {
    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("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.ccrazycoder.madhav.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 *///from  ww  w  . j  a  v  a2  s .  c om
private void sendNotification(String messageBody) {
    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_info_outline_white_36dp).setContentTitle(getString(R.string.app_name))
            .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.dotcom.jamaatAdmin.fcm.GCMListenerService.java

/**
 * Create and show a simple notification containing the received GCM
 * message./*from   w w w.j  a va 2 s . co m*/
 * <p/>
 * <p/>
 * GCM message received.
 */
public void displayNotificationInNotificationBar(Map data) {
    try {
        String messageData = data.get("message").toString();
        int notifyID = Constants.NOTIFICATION_ID;
        //String eData = data.getString("extra_data");
        String message = "";
        if (!TextUtils.isEmpty(messageData)) {
            JSONObject extra_data = new JSONObject(messageData);
            message = extra_data.optString("message");
        }

        // This intent is fired when notification is clicked

        NotificationManager notificationManager = (NotificationManager) getSystemService(
                Context.NOTIFICATION_SERVICE);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        Intent intent;
        String messages = SharedPreferencesManager.getStringPreference("notificationMessage", null);
        if (messages != null && !messages.isEmpty()) {
            messages = message + "," + messages;
            SharedPreferencesManager.setPreference("notificationMessage", messages);

            intent = new Intent(this, NotificationActivity.class);
        } else {
            SharedPreferencesManager.setPreference("notificationMessage", message);

            intent = new Intent(this, NotificationActivity.class);
        }
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        String currentMessages = SharedPreferencesManager.getStringPreference("notificationMessage", null);
        String[] messagesArray = currentMessages.split(",");

        int count = messagesArray.length;
        if (messagesArray.length == 0) {

            notificationManager.cancel(notifyID);
            return;
        }

        final String GROUP_KEY_MESSAGES = "group_key_messages";

        // Group notification that will be visible on the phone
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
        mBuilder.setTicker(getString(R.string.app_name)).setDefaults(Notification.DEFAULT_ALL)
                .setContentTitle(getString(R.string.app_name)).setSound(defaultSoundUri).setAutoCancel(true)
                .setOnlyAlertOnce(false)
                //               .setPriority(Notification.PRIORITY_MAX)
                //               .setOngoing(true)
                //               .setWhen( System.currentTimeMillis() )
                .setContentIntent(pendingIntent).setSmallIcon(R.mipmap.ic_launcher).setGroup(GROUP_KEY_MESSAGES)
                .setGroupSummary(true).build();

        NotificationCompat.Style style;
        if (count > 1) {
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            style = inboxStyle;

            mBuilder.setContentTitle(getString(R.string.app_name));

            for (String r : messagesArray) {
                inboxStyle.addLine(r);
            }
            mBuilder.setContentText(count + " new messages");
            inboxStyle.setBigContentTitle(getString(R.string.app_name));
            inboxStyle.setSummaryText(count + " new messages");
        } else {
            NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
            style = bigTextStyle;

            //            bigTextStyle.setBigContentTitle(messagesArray[0].substring(0, 10).concat(" ..."));
            bigTextStyle.setBigContentTitle(getString(R.string.app_name));
            mBuilder.setContentText(message);
            bigTextStyle.bigText(message);
            //            bigTextStyle.setSummaryText(count + " new event");
        }
        mBuilder.setStyle(style);

        NotificationManagerCompat notificationManager1 = NotificationManagerCompat.from(this);
        notificationManager1.notify(notifyID, mBuilder.build());

    } catch (Exception ex) {

    }
}

From source file:kaist.cs492c_2015.washerbrowser.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from www .  jav a 2  s. co 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.drawable.ic_stat_ic_notification).setContentTitle("Find available washer")
            .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri)
            .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }).setSmallIcon(R.drawable.washer_green)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());

    launchPopupActivity(this, message);
}

From source file:com.prova.provafirebase.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 *//* w  w w  . ja  v a2 s . c  o m*/
private void sendNotification(String messageBody) {
    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.free).setContentTitle("TINGNPADELLA").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.example.user.rideshareapp1.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from   w  ww.j  a  va2  s .  c  o  m
 */
private void sendNotification(String message) {

    String[] parts = message.split("`");

    Intent intent = new Intent(this, approve_ride.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_logo_web).setContentTitle(parts[0])
            .setContentText(parts[1] + ":" + parts[2]).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.multimediainformatika.bukabengkel.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 */// ww  w.j  a v a2  s  . co  m
private void sendNotification(String messageBody) {
    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("Know Plus").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.devnoobs.bmr.Powiadomienia.java

@Override
public void onReceive(Context c, Intent i) {
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(c).setSmallIcon(R.drawable.ic_note)
            .setContentTitle("Powiadomienie ").setContentText("Testowe powiadomienie o danej godzinie");
    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    mBuilder.setSound(alarmSound);/*from w  w  w . java 2  s . c o  m*/
    NotificationManager powiadomienie = (NotificationManager) c.getSystemService(c.NOTIFICATION_SERVICE);
    powiadomienie.notify(1, mBuilder.build());

}

From source file:com.inverita.nazarko.deeplink.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 *
 *///from   w w w  . ja  v a2 s  . co m
private void sendNotification(Map<String, String> map) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("link", map.get("link"));
    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.firebase_lockup_400).setContentTitle("FCM Message").setContentText("test")
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}