2014-06-30 68 views
2

由于某种原因,当我在我的应用程序中显示通知时会振动并发出噪音,但手机顶部不会显示横幅。我需要做一个特定的命令吗?android通知横幅不显示

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; 
    } 
+1

请包括用来生成通知的代码。 –

+0

对不起。刚添加它。 – mgild

回答

0

您的代码将正常工作,一旦你将添加下面几行:

NotificationManager n_mngr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
n_mngr.notify(NOTIF_ID, n); 
+0

实际上,我将这个通知从函数中传递出来并做出前台通知。 startForeground(notifID,notification); – mgild