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