Example usage for android.media RingtoneManager getDefaultUri

List of usage examples for android.media RingtoneManager getDefaultUri

Introduction

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

Prototype

public static Uri getDefaultUri(int type) 

Source Link

Document

Returns the Uri for the default ringtone of a particular type.

Usage

From source file:com.gsma.rcs.ri.messaging.chat.group.GroupChatIntentService.java

private Notification buildNotification(PendingIntent invitation, String title, String message) {
    // Create notification
    NotificationCompat.Builder notif = new NotificationCompat.Builder(this);
    notif.setContentIntent(invitation);//from  ww  w .  j ava2  s  . c  o  m
    notif.setSmallIcon(R.drawable.ri_notif_chat_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(message);
    return notif.build();
}

From source file:be.ac.ucl.lfsab1509.llncampus.ADE.java

/**
 * Start information update from ADE.//from  w w w . j  a v  a  2 s .c  o m
 * 
 * @param sa
 *            Activity that launches the update thread.
 * @param updateRunnable
 *            Runnable that launches the display update.
 * @param handler
 *            Handler to allow the display update at the end of the execution.
 */
public static void runUpdateADE(final ScheduleActivity sa, final Handler handler,
        final Runnable updateRunnable) {
    final Resources r = sa.getResources();

    final NotificationManager nm = (NotificationManager) sa.getSystemService(Context.NOTIFICATION_SERVICE);

    final NotificationCompat.Builder nb = new NotificationCompat.Builder(sa)
            .setSmallIcon(android.R.drawable.stat_sys_download)
            .setContentTitle(r.getString(R.string.download_from_ADE))
            .setContentText(r.getString(R.string.download_progress)).setAutoCancel(true);

    final NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.setBigContentTitle(r.getString(R.string.download_from_ADE));

    nm.notify(NOTIFY_ID, nb.build());
    new Thread(new Runnable() {
        @Override
        public void run() {

            /*
             * Fetching of code of courses to load.
             */
            ArrayList<Course> courses = Course.getList();

            if (courses == null || courses.isEmpty()) {
                // Take the context of the ScheduleActivity
                SharedPreferences preferences = new SecurePreferences(sa);
                String username = preferences.getString("username", null);
                String password = preferences.getString("password", null);
                if (username != null && password != null) {
                    UCLouvain.downloadCoursesFromUCLouvain(sa, username, password, new Runnable() {
                        public void run() {
                            runUpdateADE(sa, handler, updateRunnable);
                        }
                    }, handler);
                }

            }

            /*
             * Number of weeks. To download all the schedule, the numbers go from 0 to 51
             * (0 = beginning of first semester, 51 = ending of the September exams session).
             */
            String weeks = getWeeks();

            /*
             * Fetching data from ADE and updating the database
             */
            int nbError = 0;
            int i = 0;
            ArrayList<Event> events;
            for (Course course : courses) {
                i++;
                nb.setProgress(courses.size(), i, false);
                nb.setContentText(r.getString(R.string.download_for) + " " + course.getCourseCode() + "...");
                nm.notify(NOTIFY_ID, nb.build());
                events = ADE.getInfo(course.getCourseCode(), weeks);
                if (events == null) {
                    nbError++;
                    inboxStyle.addLine(course.getCourseCode() + " : " + r.getString(R.string.download_error));
                } else {
                    // Removing old data
                    LLNCampus.getDatabase().delete("Horaire", "COURSE = ?",
                            new String[] { course.getCourseCode() });
                    // Adding new data
                    for (Event e : events) {
                        ContentValues cv = e.toContentValues();
                        cv.put("COURSE", course.getCourseCode());
                        if (LLNCampus.getDatabase().insert("Horaire", cv) < 0) {
                            nbError++;
                        }
                    }
                    inboxStyle.addLine(course.getCourseCode() + " : " + events.size() + " "
                            + r.getString(R.string.events));
                    nb.setStyle(inboxStyle);
                }
            }

            nb.setProgress(courses.size(), courses.size(), false);

            if (nbError == 0) {
                nb.setContentText(r.getString(R.string.download_done));
                inboxStyle.setBigContentTitle(r.getString(R.string.download_done));
                nb.setSmallIcon(android.R.drawable.stat_sys_download_done);
                nb.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
            } else {
                nb.setContentText(r.getString(R.string.download_done) + ". " + r.getString(R.string.nb_error)
                        + nbError + " :/");
                inboxStyle.setBigContentTitle(r.getString(R.string.download_done) + ". "
                        + r.getString(R.string.nb_error) + nbError + " :/");
                nb.setSmallIcon(android.R.drawable.stat_notify_error);
                nb.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
            }
            nb.setStyle(inboxStyle);
            nm.notify(NOTIFY_ID, nb.build());

            handler.post(updateRunnable);

        }
    }).start();
}

From source file:com.weddingsingers.wsapp.fcm.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.  com
private void sendNotification(String messageBody, String action) {
    Intent intent = new Intent(this, SplashActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    switch (action) {
    case ACTION_RESERVATION_LIST: {
        intent.putExtra(SplashActivity.EXTRA_FRAGNAME, MainActivity.FRAG_RESERVATION_MGM);
        break;
    }
    case ACTION_RESERVED_CUSTOMER: {
        intent.putExtra(SplashActivity.EXTRA_FRAGNAME, MainActivity.FRAG_RESERVED_CUSTOMER);
        break;
    }
    case ACTION_SCHEDULE_MGM: {
        intent.putExtra(SplashActivity.EXTRA_FRAGNAME, MainActivity.FRAG_SCHEDULE_MGM);
        break;
    }
    case ACTION_VIDEO: {
        intent.putExtra(SplashActivity.EXTRA_FRAGNAME, MainActivity.FRAG_VIDEO);
        break;
    }
    case ACTION_CHATTING: {
        intent.putExtra(SplashActivity.EXTRA_FRAGNAME, ChattingActivity.class);
        break;
    }
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.manifest_ic_wedding_singers_512).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.abajeli.wearable.gesturecadabra.MainActivity.java

public void parla(String txt) {
    //ttobj.speak(txt, TextToSpeech.QUEUE_FLUSH, null);

    try {//from   w  w  w  .  j a  v  a 2  s  .  c o  m
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        long[] vibrationPattern = { 0, 100, 0, 0 };
        final int indexInPatternToRepeat = -1;
        Utils.vibratePattern(this, vibrationPattern, indexInPatternToRepeat);

        //Ringtone r = RingtoneManager.getRingtone(baseContext, notification);
        //r.play();
    } catch (Exception e) {
        e.printStackTrace();
    }

    /*
            Intent viewIntent = new Intent(mContext, NotificationActivity.class);
            viewIntent.putExtra(EXTRA_EVENT_ID, NOTIFICATION_ID);
            PendingIntent viewPendingIntent =
        PendingIntent.getActivity(mContext, 0, viewIntent, 0);
            
    // Create a WearableExtender to add functionality for wearables
            NotificationCompat.WearableExtender wearableExtender =
        new NotificationCompat.WearableExtender()
                .setHintHideIcon(true);
            //.setBackground(mBitmap);
            
    // Create a NotificationCompat.Builder to build a standard notification
    // then extend it with the WearableExtender
            NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(mContext)
                //.setSmallIcon(R.drawable.ic_event)
                .setContentTitle("eventTitle")
                .setContentText("eventLocation")
                .extend(wearableExtender)
                .setContentIntent(viewPendingIntent);
            
            
            
            
            
            
            // Get an instance of the NotificationManager service
            NotificationManagerCompat notificationManager =
        NotificationManagerCompat.from(mContext);
            
    // Issue the notification with notification manager.
            notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
            
            */

}

From source file:com.android.emailcommon.provider.Account.java

public Account() {
    mBaseUri = CONTENT_URI;//  ww  w.  j a va  2 s  .com

    // other defaults (policy)
    mRingtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString();
    mSyncInterval = -1;
    mSyncLookback = -1;
    mFlags = 0;
}

From source file:com.brayanarias.alarmproject.activity.AlarmScreenActivity.java

private void playRingtone(String tone) {
    mediaPlayer = new MediaPlayer();
    try {//from www .jav  a  2 s  .  com
        Uri ringtoneUri;
        if (tone.equals("default")) {
            ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
        } else {
            ringtoneUri = Uri.parse(tone);
        }

        if (ringtoneUri != null) {
            mediaPlayer.setDataSource(this, ringtoneUri);
            mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
            mediaPlayer.setLooping(true);
            mediaPlayer.prepare();
            AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            actualVolume = audioManager.getStreamVolume(AudioManager.STREAM_ALARM);
            incrementVolume();
            mediaPlayer.start();
            audioManager.setStreamVolume(AudioManager.STREAM_ALARM, 1, 0);
        }
    } catch (Exception e) {
        Log.e(tag, e.getLocalizedMessage(), e);
    }
}

From source file:com.zaparound.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 *//*  w  ww.j a va  2s.  com*/
private void sendNotificationZapRequest(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("CHECKIN_TAB_POS", 1);
    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.unfc.choicecustomercare.gcmservices.MyGcmListenerService.java

private void sendNotificationForTakeBreakAccept(String message, String fromId, String toId) {

    boolean loggedOut = CustomPreferences.getPreferences(Constants.PREF_LOGGED_OUT, false);
    Intent intent;/*w  w  w  .  j  a  va  2  s  .c om*/
    if (loggedOut) {
        intent = new Intent(this, LoginActivity.class);

    } else {
        intent = new Intent(this, MainActivity.class);
    }

    intent.setAction("takeBreakAccept");
    intent.putExtra("fromId", fromId);
    intent.putExtra("toId", toId);
    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);
    //
    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(Constants.TAKE_A_BREAK_NOTIFICATION_ID, notificationBuilder.build());

}

From source file:at.flack.receiver.FacebookReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();/*from w w  w  .java2 s . co m*/
    try {
        if (main instanceof FbMessageOverview && bundle.getString("type").equals("message")) {
            ((FbMessageOverview) main).addNewMessage(
                    new FacebookMessage(bundle.getString("fb_name"), bundle.getString("fb_message"),
                            bundle.getString("fb_img"), bundle.getLong("fb_id"), bundle.getString("fb_tid")));
        } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("readreceipt")) {
            ((FbMessageOverview) main).changeReadReceipt(bundle.getLong("fb_time"),
                    bundle.getLong("fb_reader"));
        } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("typ")) {
            ((FbMessageOverview) main).changeTypingStatus(bundle.getLong("my_id"), bundle.getLong("fb_id"),
                    bundle.getBoolean("fb_from_mobile"), bundle.getInt("fb_status"));
        } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("img_message")) {
            ((FbMessageOverview) main).addNewMessage(new FacebookImageMessage(bundle.getString("fb_name"),
                    bundle.getString("fb_image"), bundle.getString("fb_preview"), bundle.getString("fb_img"),
                    bundle.getLong("fb_id"), bundle.getString("fb_tid")));
        } else if (bundle.getString("type").equals("read")) {
            killNotification(context,
                    new MarkAsRead(bundle.getString("fb_tid"), bundle.getBoolean("fb_markas")));
        } else if (bundle.getString("type").equals("message")
                || bundle.getString("type").equals("img_message")) {
            sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
            if (!sharedPrefs.getBoolean("notification_fbs", true))
                return;
            notify = sharedPrefs.getBoolean("notifications", true);
            vibrate = sharedPrefs.getBoolean("vibration", true);
            headsup = sharedPrefs.getBoolean("headsup", true);
            led_color = sharedPrefs.getInt("notification_light", -16776961);
            boolean all = sharedPrefs.getBoolean("all_fb", true);

            if (notify == false)
                return;
            if (bundle.getLong("fb_id") == bundle.getLong("my_id")) {
                return;
            }

            NotificationCompat.Builder mBuilder = null;
            boolean use_profile_picture = false;
            Bitmap profile_picture = null;

            String origin_name = bundle.getString("fb_name");

            try {
                profile_picture = RoundedImageView.getCroppedBitmap(Bitmap.createScaledBitmap(
                        ProfilePictureCache.getInstance(context).get(origin_name), 200, 200, false), 300);
                use_profile_picture = true;
            } catch (Exception e) {
                use_profile_picture = false;
            }

            Resources res = context.getResources();

            if (bundle.getString("type").equals("img_message")) {
                bundle.putString("fb_message", res.getString(R.string.fb_notification_new_image));
            }

            int lastIndex = bundle.getString("fb_message").lastIndexOf("=");
            if (lastIndex > 0 && Base64.isBase64(bundle.getString("fb_message").substring(0, lastIndex))) {
                mBuilder = new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.raven_notification_icon).setContentTitle(origin_name)
                        .setColor(0xFF175ea2)
                        .setContentText(res.getString(R.string.sms_receiver_new_encrypted_fb))
                        .setAutoCancel(true);
                if (use_profile_picture && profile_picture != null) {
                    mBuilder = mBuilder.setLargeIcon(profile_picture);
                } else {
                    mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name,
                            context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200));
                }
            } else { // normal or handshake

                if (bundle.getString("fb_message").charAt(0) == '%'
                        && (bundle.getString("fb_message").length() == 10
                                || bundle.getString("fb_message").length() == 9)) {
                    if (lastIndex > 0
                            && Base64.isBase64(bundle.getString("fb_message").substring(1, lastIndex))) {
                        mBuilder = new NotificationCompat.Builder(context).setContentTitle(origin_name)
                                .setColor(0xFF175ea2)
                                .setContentText(res.getString(R.string.sms_receiver_handshake_received))
                                .setSmallIcon(R.drawable.notification_icon).setAutoCancel(true);
                        if (use_profile_picture && profile_picture != null) {
                            mBuilder = mBuilder.setLargeIcon(profile_picture);
                        } else {
                            mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name,
                                    context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200));
                        }
                    } else {
                        return;
                    }
                } else if (bundle.getString("fb_message").charAt(0) == '%'
                        && bundle.getString("fb_message").length() >= 120
                        && bundle.getString("fb_message").length() < 125) {
                    if (lastIndex > 0
                            && Base64.isBase64(bundle.getString("fb_message").substring(1, lastIndex))) {
                        mBuilder = new NotificationCompat.Builder(context).setContentTitle(origin_name)
                                .setColor(0xFF175ea2)
                                .setContentText(res.getString(R.string.sms_receiver_handshake_received))
                                .setSmallIcon(R.drawable.notification_icon).setAutoCancel(true);
                        if (use_profile_picture && profile_picture != null) {
                            mBuilder = mBuilder.setLargeIcon(profile_picture);
                        } else {
                            mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name,
                                    context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200));
                        }
                    } else {
                        return;
                    }
                } else if (all) { // normal message
                    mBuilder = new NotificationCompat.Builder(context)
                            .setSmallIcon(R.drawable.raven_notification_icon).setContentTitle(origin_name)
                            .setColor(0xFF175ea2).setContentText(bundle.getString("fb_message"))
                            .setAutoCancel(true).setStyle(new NotificationCompat.BigTextStyle()
                                    .bigText(bundle.getString("fb_message")));

                    if (use_profile_picture && profile_picture != null) {
                        mBuilder = mBuilder.setLargeIcon(profile_picture);
                    } else {
                        mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name,
                                context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200));
                    }
                } else {
                    return;
                }
            }
            // }
            Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            mBuilder.setSound(alarmSound);
            mBuilder.setLights(led_color, 750, 4000);
            if (vibrate) {
                mBuilder.setVibrate(new long[] { 0, 100, 200, 300 });
            }

            Intent resultIntent = new Intent(context, MainActivity.class);
            resultIntent.putExtra("FACEBOOK_NAME", origin_name);

            TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(1,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            if (Build.VERSION.SDK_INT >= 16 && headsup)
                mBuilder.setPriority(Notification.PRIORITY_HIGH);
            if (Build.VERSION.SDK_INT >= 21)
                mBuilder.setCategory(Notification.CATEGORY_MESSAGE);

            final NotificationManager mNotificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);

            if (!MainActivity.isOnTop)
                mNotificationManager.notify(8, mBuilder.build());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.shivshankar.MyFirebaseMessagingService.java

private void sendNotification(String strTitle, String strMsg) {
    Log.d("TAGRK", "Preparing to send notification...: " + strTitle + "  Msg: " + strMsg);
    NotificationManager mNotificationManager = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);

    Intent intent;/*  w  ww .ja v  a2s  .co  m*/
    if (AppPreferences.getPrefs().getBoolean(commonVariables.KEY_IS_SELLER, false))
        intent = new Intent(this, MainActivitySeller.class);
    else
        intent = new Intent(this, MainActivityBuyer.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    int requestID = (int) System.currentTimeMillis();
    PendingIntent contentIntent = PendingIntent.getActivity(MyFirebaseMessagingService.this, requestID, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setContentTitle(strTitle)
            .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(strMsg)).setContentText(strMsg)
            .setPriority(NotificationCompat.PRIORITY_MAX).setWhen(0).setVibrate(new long[] { 100, 100, 0, 0 });

    mBuilder.setSmallIcon(R.drawable.ic_noti_fcm);
    try {
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
        r.play();
    } catch (Exception e) {
        e.printStackTrace();
    }

    mBuilder.setAutoCancel(true);
    if (!strMsg.contains("Your OTP is"))
        mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(NOTIFICATION_ID++, mBuilder.build());
    Log.d("TAGRK", "Notification sent successfully.");
}