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:cn.studyjams.s2.sj0119.NForget.AlarmReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    int mReceivedID = Integer.parseInt(intent.getStringExtra(ReminderEditActivity.EXTRA_REMINDER_ID));

    // Get notification title from Reminder Database
    ReminderDatabase rb = new ReminderDatabase(context);
    Reminder reminder = rb.getReminder(mReceivedID);
    String mTitle = reminder.getTitle();

    // Create intent to open ReminderEditActivity on notification click
    Intent editIntent = new Intent(context, ReminderEditActivity.class);
    editIntent.putExtra(ReminderEditActivity.EXTRA_REMINDER_ID, Integer.toString(mReceivedID));
    PendingIntent mClick = PendingIntent.getActivity(context, mReceivedID, editIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Create Notification
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))
            .setSmallIcon(R.drawable.ic_alarm_on_white_24dp)
            .setContentTitle(context.getResources().getString(R.string.app_name)).setTicker(mTitle)
            .setContentText(mTitle).setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setContentIntent(mClick).setAutoCancel(true).setOnlyAlertOnce(true);

    NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nManager.notify(mReceivedID, mBuilder.build());
}

From source file:com.photobox.android.iris.MyFirebaseMessagingService.java

private void sendNotification(RemoteMessage.Notification messageNotification, Map messageData) {
    Log.d(TAG, "Entering Send notification");

    Intent callIntent = new Intent(Intent.ACTION_CALL,
            Uri.parse("tel:" + (String) messageData.get("phoneNumber")));
    callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, callIntent, PendingIntent.FLAG_ONE_SHOT);

    String messageType = (String) messageData.get("type");
    Log.d(TAG, "messageType: " + messageType);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = null;

    if ("call".equals(messageType)) {
        Log.d(TAG, "inside call: ");
        notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(android.R.drawable.stat_notify_missed_call)
                .setContentTitle(messageNotification.getTitle()).setContentText(messageNotification.getBody())
                .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent)
                .addAction(0, "Call", pendingIntent);
    } else {//from w w w.  ja v a  2s.co  m
        Log.d(TAG, "inside sms: ");
        notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(android.R.drawable.sym_action_email)
                .setContentTitle(messageNotification.getTitle()).setContentText(messageNotification.getBody())
                .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);
    }

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

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

From source file:de.escoand.readdaily.PushMessageService.java

@Override
public void onMessageReceived(final RemoteMessage remoteMessage) {
    RemoteMessage.Notification notification = remoteMessage.getNotification();
    String title = getString(R.string.app_title);
    String message = "";

    Intent intent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    LogHandler.log(Log.WARN, "received message");

    // get title//w ww.  j  a va  2 s.  c o m
    if (notification != null && notification.getTitle() != null && !notification.getTitle().isEmpty())
        title = notification.getTitle();

    // get message
    if (notification != null && notification.getBody() != null && !notification.getBody().isEmpty())
        message = notification.getBody();
    else if (remoteMessage.getData().containsKey("message"))
        message = remoteMessage.getData().get("message");

    // build notification
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.icon_notification)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
            .setContentTitle(title).setContentText(message).setAutoCancel(true)
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setContentIntent(pendingIntent);

    ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE))
            .notify((int) remoteMessage.getSentTime(), builder.build());
}

From source file:MainActivity.java

public void clickSound(View view) {
    Uri notificationSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), notificationSoundUri);
    ringtone.play();//from   ww  w.  jav  a2s .  c  om
}

From source file:com.example.finalfcm.MyFirebaseMessagingService.java

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("Message From Neha")
            .setContentText(messageBody).setAutoCancel(true)
            .setStyle(new NotificationCompat.BigPictureStyle()
                    .bigPicture(((BitmapDrawable) getResources().getDrawable(R.drawable.dog)).getBitmap()))
            .setSound(defaultSoundUri).setContentIntent(pendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());
}

From source file:com.orca.dotz.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 a2  s  .  c o m
private void sendNotification(String messageBody) {
    Intent intent = new Intent(this, SalonLists.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("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.letsgood.letschat.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*from   w  w  w .j a  v  a 2s . c  o m*/
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, SKChatActivity.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(getString(R.string.app_name))
            .setContentText(message).setSound(defaultSoundUri).setContentIntent(pendingIntent)
            .setAutoCancel(true);

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

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

From source file:com.mjhram.geodata.gcm_client.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*w w  w  . j a  v a  2  s. c  o m*/
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, GpsMainActivity.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(getString(R.string.gcmClientGcmMsg))
            .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.pr.carjoin.chat.MyFirebaseMessagingService.java

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, 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("CarJoin").setContentText(messageBody)
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

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

    notificationManager.notify(0, notificationBuilder.build());
}

From source file:com.phillips.phillipscs.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param requestId GCM message received.
 *///  www  . java  2  s .c  o  m
private void sendNotification(String requestId, String message) {
    Intent intent = new Intent(this, RequestDetailActivity.class);
    intent.putExtra(Constants.KEY_REQUEST_ID, requestId);
    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_name).setContentTitle("Shri. Suparno Satpathy")
            .setContentText(message)
            .setLargeIcon(
                    Bitmap.createBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.philips_main)))
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

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

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