2016-03-01 44 views
0
private void Notify(String notificationTitle, String notificationMessage){ 

     NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 

     @SuppressWarnings("deprecation") 

     Notification notification = new Notification(R.drawable.logob,"New Message", System.currentTimeMillis()); 
     Intent notificationIntent = new Intent(this,NotificationView.class); 
     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); 

     notification.setLatestEventInfo(foradmin.this, notificationTitle,notificationMessage, pendingIntent); 
     notificationManager.notify(9999, notification); 
    } 

試圖生成的應用程序的通知,但我得到的錯誤無法解決setLatestEventInfo()方法。我想生成的應用程序的通知,但我得到的錯誤無法解決setLatestEventInfo()方法

+0

的可能的複製[無法解決方法setLatestEventInfo(http://stackoverflow.com/questions/32345768/cannot-resolve-method-setlatesteventinfo)? –

+0

actully我想創建時,我在我的項目選擇sendtoapp選項,然後一個通知發送到所有registerd移動沒有在我的數據庫 – sonali

+0

PLZ有人幫我... – sonali

回答

0

嘗試這樣的。它的工作原理perfectly.Hope這個helps.Thanks

PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 1, intent, 0); 

     Notification.Builder builder = new Notification.Builder(MainActivity.this); 

     builder.setAutoCancel(false); 
     builder.setTicker("this is ticker text"); 
     builder.setContentTitle("WhatsApp Notification");    
     builder.setContentText("You have a new message"); 
     builder.setSmallIcon(R.drawable.ic_launcher); 
     builder.setContentIntent(pendingIntent); 
     builder.setOngoing(true); 
     builder.setSubText("This is subtext..."); //API level 16 
     builder.setNumber(100); 
     builder.build(); 

     myNotication = builder.getNotification(); 
     manager.notify(11, myNotication); 
+0

當我指上文提及正在運行的應用強制關閉後codethen並且誤差被示出的Java。 lang.NoClassDefFoundError:android.app.Notification $生成器....... – sonali

+0

NotificationCompat.Builder建設者=新NotificationCompat.Builder(本);這是我的問題的解決方案...感謝您的努力 – sonali

相關問題