Hey guys so iv'e recently been trying to program a timer where once the timer hits 0 a notification appears telling the user what happened and will play a sound along with it. Ive been able to get my default phone notification sound to work but i cant seem to get this custom sound to work. Heres my code am I missing something?
Uri sound = Uri.parse("android.resource://com.example.jmac.spawny"+R.raw.fresh_overs);
PendingIntent intent = PendingIntent.getActivity(this, 100, new Intent(this, Guardian.class), 0);
NotificationCompat.Builder nb = new NotificationCompat.Builder(this);
nb.setSmallIcon(R.drawable.spawnymascot);
nb.setSound(sound);
nb.setContentTitle("Overs Up Bro!");
nb.setContentText("Click to return to Guardian Screen");
nb.setContentIntent(intent);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(100, nb.build());
您没有使用斜杠将包名称与资源ID分开:
Uri sound = Uri.parse("android.resource://com.example.jmac.spawny/"+R.raw.fresh_overs);
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.