Android Notification to play sound only

后端 未结 4 2110
清歌不尽
清歌不尽 2020-12-09 12:41

I have a countdown timer in my activity and when it reaches zero I send a notification to the status bar which also plays a custom wav file to alert the user. I only want t

4条回答
  •  一整个雨季
    2020-12-09 13:31

    Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    
    Notification mNotification = new Notification.Builder(this)
    
                .setContentTitle("New Post!")
                .setContentText("Here's an awesome update for you!")
                .setSmallIcon(R.drawable.ic_lancher)
                .setContentIntent(pIntent)
                .setSound(soundUri)
                .build();
    

提交回复
热议问题