首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android Notification Builder Sound

Android Notification Builder Sound
EN

Stack Overflow用户
提问于 2013-10-17 19:28:46
回答 1查看 1.1K关注 0票数 0

我正在使用一个通知建造器,并希望声音,振动和光。振动和光线工作正常,但声音不想播放。我在这里尝试了许多解决方案,但大多数都是针对弃用版本的。在下面的代码中,你可以看到我在做什么。我尝试了alamsound和sound,但都不起作用。我需要任何许可吗?

代码语言:javascript
复制
    public void createTestNotification(){
    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    long[] vibrate = { 0, 100, 200, 300 };
    NotificationManager nm= (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
    Uri sound = Uri.parse("android.resource://com.uks.uksnavigation/" + R.raw.notification);


    Intent intent = new Intent(this.getActivity(), MainActivity.class);
    intent.setAction("nachricht");
    PendingIntent pIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0);

    Notification.Builder mBuilder =
            new Notification.Builder(getActivity())
    .setContentIntent(pIntent)
            .setSmallIcon(R.drawable.ic_stat_mail_aktiv)
            .setContentTitle("New Message")
            .setContentText("Nachrichten text text text")
            .setSound(sound)
            .setVibrate(vibrate)
            .setLights(Color.BLUE, 500, 500);

    nm.notify(1, mBuilder.build());     


}
EN

回答 1

Stack Overflow用户

发布于 2013-10-18 12:09:23

使用Uri.parse("android.resource://com.uks.uksnavigation/raw/notification")

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19425491

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档