Play notification default sound only (Android)

前端 未结 3 1216
半阙折子戏
半阙折子戏 2020-12-11 01:10

How can I play a notification sound only (without firing a status bar notification)? I want the notification default sound and play it exactly as a notification sound. Is it

3条回答
  •  無奈伤痛
    2020-12-11 01:31

    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(context.getApplicationContext(), notification);
    r.play();
    

提交回复
热议问题