2 markdowneide markdowneide 于 2013.06.14 11:35 提问

如何在status bar中显示通知?

我在 activity 中创建了 notification

Notification n = new Notification.Builder(getApplicationContext())
    .setContentTitle("New mail from " + sender)
    .setContentText(subject)
    .setSmallIcon(R.drawable.notification)
    .build();

现在在status/notification bar 中如何显示通知,并且还带有声音?

1个回答

shaojie519
shaojie519   2013.06.14 11:51
已采纳
NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
notification.sound = uri; //比如 Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notificationManager.notify(0, notification);
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!