java - 通知管理器

标签 java android notifications

我想为我的应用创建通知

它告诉我构造函数Notification(,,)已被弃用

并且 .setLatestEventInfo() 方法也已弃用

我应该做什么?

这是类代码:

public class ReminderService extends WakeReminderIntentService {

public ReminderService() {
    super ("ReminderService");
}

@Override
void doReminderWork(Intent intent) {
    long rowid = intent.getExtras().getLong(ReminderProvider.COLUMN_ROWID);

    NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    Intent notificationIntent = new Intent (this, ReminderEditActivity.class);
    notificationIntent.putExtra(ReminderProvider.COLUMN_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;
    int id = (int) ((long) rowid);
    mgr.notify(id, note);

}

}

最佳答案

关于java - 通知管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15990295/

相关文章:

java - 将日期选择器值放入 java 中的列表中

Android Maven archtype 项目布局在 ADT 图形编辑器上显示不正确

Android通知大图标,有没有办法去掉右下角的小图标?

java - 无法识别用于展开/折叠区域的小部件类型

java - 信息 : Transport Used for JDBC connection: null + Apache Hive

java - 如何将参数传递给 ScheduledMethodRunnable 方法

Android如何发布测试版App

android - 火力地堡安卓 : File upload cancellation

java - 如何删除或取消alarmManager中的所有pendingIntent?

iphone - 制作我自己的 UIControl 事件并触发它?