简体   繁体   中英

Notification sound from My Application when in call

My application sends notification on set time always with the custom ringtone and vibration(if the user as set the vibrate option). But the same is not going well when in call. My notification code looks as below:

NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotification = new Notification.Builder(context)
            .setContentTitle(title)
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setSmallIcon(image)
            .setSound(mRingtoneUri)
            .setContentIntent(pi)
     //     .setPriority(Notification.PRIORITY_MAX) //does not work
            .build();

//        mNotification.priority = mNotificationManager.IMPORTANCE_HIGH;// does not work

    if (isVibrate()) {
        mNotification.defaults |= Notification.DEFAULT_VIBRATE;
    }

//            mNotification.flags |= Notification.FLAG_NO_CLEAR;// does not work
    mNotification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;// does not work

    mNotificationManager.notify(id, mNotification);

Tried setting FLAG on notification, PRIORITY to MAX, IMPORTANCE_HIGH but noting lets the sound to play when on Call. But Vibration set works even on Call.

I did not find any related questions posted on stack. Any help is appreciated. Thanks.

There is no way to achieve what I was trying to do, the reason is CALL has been set to highest priority on any other operation. So any app can not get you the tone when on call but the only thing to notify the user saying there is something going with your app is by alert with vibrate (Sorry for making it little late).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM