简体   繁体   中英

Cannot resolve setLatestEventInfo the sdk version i am using is 23

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);

What is wrong in the above code?.............................................................................................................................................

ya because it is deprecated method. you can use

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM