简体   繁体   English

通话时来自“我的应用程序”的通知声音

[英]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. 尝试将FLAG设置为通知,PRIORITY设置为MAX,IMPORTANCE_HIGH,但注意在通话时可以播放声音。 But Vibration set works even on Call. 但是振动设置甚至可以在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. 无法实现我试图做的事情,原因是在任何其他操作上CALL都被设置为最高优先级 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). 因此,任何应用程序都无法在通话时让您听到提示音,但唯一可以通知用户说您的应用程序有问题的是振动提示(抱歉,为时已晚)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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