2014-09-27 66 views
0

我试图通过这个安卓:如何显示通知文本

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.front2).setContentTitle("WAKE ME UP!").setContentText(text); 


     Intent intent1 = new Intent(this.getApplicationContext(), MainActivity.class); 

     intent1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); 

     PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT); 

     mBuilder.setContentIntent(pendingNotificationIntent); 
     NotificationManager mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE); 
     // mId allows you to update the notification later on. 
     mNotificationManager.notify(0, mBuilder.build()); 

但显示通知,目前,它没有表现出像其他应用程序的文本(我的意思是:通过notifycation栏上线diplay文本行)我的代码只是显示图标con通知栏。 如果我想看到消息,我必须打开notifycation下拉列表。

问:我该怎么办像其他应用程序的通知

感谢您的帮助

回答

0

也许它可以帮助你:

mBuilder.setTicker("some text"); 
+0

非常感谢。 – Tom 2015-07-10 06:11:29

1

试试这个它会工作 mBuilder.setContentTitle (“通知警报,点击我!”); mBuilder.setContentText(“嗨,这是Android通知细节!”);