Android 通知栏中不显示我的通知消息,仅显示标题?

Android 通知栏中不显示我的通知消息,仅显示标题?,android,Android,我试图在通知消息中显示数据库内容(只有两个单词),但只有标题显示为什么?。 第二个问题:我使用AlarmManager每1分钟触发一个intentservice类(包含此代码的类),但如果data==null,则在我的情况下通知我,这是不应该发生的 ShowTimeDB RetrieverDB =new ShowTimeDB(this); RetrieverDB.open(); String data = RetrieverDB.getShowNotify(); Ret

我试图在通知消息中显示数据库内容(只有两个单词),但只有标题显示为什么?。 第二个问题:我使用AlarmManager每1分钟触发一个intentservice类(包含此代码的类),但如果data==null,则在我的情况下通知我,这是不应该发生的

 ShowTimeDB RetrieverDB =new ShowTimeDB(this);
    RetrieverDB.open();
    String data = RetrieverDB.getShowNotify();
    RetrieverDB.close();

    if (data!=null){

        nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);




        Intent intent=new Intent(this,TodayShow.class);
        PendingIntent pi= PendingIntent.getActivity(this, 0, intent, 0);
        CharSequence x=(CharSequence) data;
        Notification n=new Notification(R.drawable.ic_launcher,"YOU HAVE SHOw" ,System.currentTimeMillis());
        n.setLatestEventInfo(this, "ShowTime", x, pi);
        n.defaults=Notification.DEFAULT_ALL;

        nm.notify(uniqueID,n);

尝试使用Notification.Builder而不是Notification。使用new Notification()生成通知对象已被弃用,取而代之的是使用Notification.Builder类。还有一个NotificationCompat.Builder,用于与1.6版本的兼容性


我不知道你的第二个问题是什么意思。

谢谢,关于第二个问题,当(if(data!=null))数据内容等于null时,上面的代码在if块中的代码不应该工作,但在我的情况下,尽管数据等于null,代码仍然工作!