SetLatestEventInfo method cannot be resolved

I am trying to implement a reminder function for my application, which is API 23.

However, the reminder function contains an error in which the setLatestEventInfo method cannot be resolved.

enter image description here

I did some research and it turns out that this method is deprecated in API 23. I know that there are similar issues, but the solutions do not work for me.

The following are relevant codes:

public class ReminderService extends WakeReminderIntentService { public ReminderService() { super("ReminderService"); } @Override void doReminderWork(Intent intent) { Log.d("ReminderService", "Doing work."); Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID); NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(this, ReminderEditActivity.class); notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId); PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT); Notification note=new Notification(android.R.drawable.stat_sys_warning, getString(R.string.notify_new_task_message), System.currentTimeMillis()); note.setLatestEventInfo(this, getString(R.string.notify_new_task_title), getString(R.string.notify_new_task_message), pi); note.defaults |= Notification.DEFAULT_SOUND; note.flags |= Notification.FLAG_AUTO_CANCEL; // An issue could occur if user ever enters over 2,147,483,647 tasks. (Max int value). // I highly doubt this will ever happen. But is good to note. int id = (int)((long)rowId); mgr.notify(id, note); } } 

How can I solve this problem without lowering the API level?

+1
java android android-notifications
Feb 23 '16 at 6:56
source share
1 answer

Use NotificationCompat.Builder to create your notifications, as in the documentation .

You can check the methods setTicker , setSmallIcon , setContentTitle , setContentText , setContentIntent , setAutoCancel , setDefaults to reproduce your behavior.

0
Mar 01 '16 at 13:57
source share



All Articles