简体   繁体   中英

sound notification when message received from mixpanel

I have integrated mixpanel in my android app code, and I am getting push notifications but I want to hear the default notification sound when the message arrives. So I added the following:

    public class notificationReceiver extends BroadcastReceiver {
    @Override
      public void onReceive(Context context, Intent MainActivity) {
         NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
Uri notification =  RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        mBuilder.setSound(notification);
Ringtone r = RingtoneManager.getRingtone(context.getApplicationContext(),    notification);
    r.play();  }
}

Any reason why this doesn't make sound to the mixpanel notification? Thank you!

您必须在通知生成器中添加此行代码

mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);

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