嘿伙计们,所以我最近一直试图设定一个计时器,一旦计时器点击0,就会出现一条告知用户发生了什么的通知,并会随之发出声音。我已经能够使我的默认电话通知声音工作,但我似乎无法使这个自定义声音工作。继承我的代码我错过了什么?
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());
答案 0 :(得分:2)
您缺少正斜杠以将您的包名称与资源ID分开:
Uri sound = Uri.parse("android.resource://com.example.jmac.spawny/"+R.raw.fresh_overs);