Android notification setSound is not working

后端 未结 8 1714
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 04:46

In my hybrid Cordova Android app targeting API 23+ I want to use a custom sound for notifications. To that end I have done the following

  • In plugin.xml
8条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 04:58

     Notification.Builder builder = new Notification.Builder(context);
        builder.setContentTitle(mTitle);
        builder.setContentText(mContentText);
        builder.setSmallIcon(R.mipmap.ic_launcher);
    
        builder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
        builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
        builder.setDefaults(Notification.DEFAULT_ALL);
    

    Use this to work with sound, I hope it will solve your problem, Cheers!

提交回复
热议问题