2015-10-17 76 views
2
Notification notification = new Notification(R.drawable.stat_sample, 
         getText(R.string.new_friend_request_exist), 
         System.currentTimeMillis()); 

Intent i = new Intent(this, UnApprovedFriendList.class); 
i.putExtra(FriendInfo.FRIEND_LIST, tmp); 

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, 
     i, 0); 

notification.setLatestEventInfo(this, getText(R.string.new_friend_request_exist), 
     "You have new friend request(s)", 
     contentIntent); 

上述代码有什么问题?......................... .................................................. .................................................. ................无法解析setLatestEventInfo我正在使用的sdk版本是23

+0

setLatestEventInfo不能得到解决 – ra11

回答

2

雅,因为它是不赞成使用的方法。 可以使用

NotificationCompat.Builder builder = new NotificationCompat.Builder(
        this); 
      myNotification = builder.setContentIntent(contentIntent) 
        .setSmallIcon(R.drawable.yourstring) 
        .setTicker(notificationText).setWhen(System.currentTimeMillis()) 
        .setAutoCancel(true) 
        .setContentTitle(getText(R.string.title)) 
        .setContentText(notificationText).build(); 
+1

还必须有没有NotificationCompat的方式 - 任何人都知道如何? – ligi

相关问题