出于某种原因,当我在我的应用程序中发出通知时,它会振动并发出噪音,但手机顶部没有出现横幅。是否需要特定的命令才能让它执行此操作?
public Notification getNotification(String message) {
Intent intent = new Intent(serviceContext, NotificationGenerator.class); //not sure how
// this class i pass matters
PendingIntent pi = PendingIntent.getActivity(serviceContext, 0, intent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(serviceContext)
.setContentTitle(message)
.setContentText(message)
.setSmallIcon(R.drawable.dominos_icon)
.setContentIntent(pi);
Notification n = builder.build();
n.defaults = Notification.DEFAULT_ALL;
return n;
}
最佳答案
添加以下行后,您的代码将正常运行:
NotificationManager n_mngr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
n_mngr.notify(NOTIF_ID, n);
关于java - android通知横幅不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24497578/