2013-03-26 76 views
0

我試圖在通知消息中顯示數據庫內容(只有兩個字),但只有標題顯示爲什麼? 第二個問題:我用AlarmManager觸發intentservice類(類內容的代碼),每1分鐘,但如果數據== 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); 

回答

0

嘗試通知我使用Notification.Builder而不是通知。使用新的通知()建立通知對象已被棄用,以支持使用Notification.Builder類。這也是一個NotificationCompat.Builder,與1.6版本兼容。

我不確定你的第二個問題是什麼意思。

+0

謝謝關於第二個問題上面這段代碼的時候(if(data!= null))當數據內容等於null時代碼裏面的代碼塊應該不起作用,但是在我的情況下儘管數據代碼工作等於null! – 2013-03-26 19:21:29

+0

if(!data.equals(null)) – 2013-03-26 19:27:20

相關問題