Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通知管理器_Java_Android_Notifications - Fatal编程技术网

Java 通知管理器

Java 通知管理器,java,android,notifications,Java,Android,Notifications,我想为我的应用程序创建通知 它告诉我构造函数通知(,)已弃用 另外,setLateStevenInfo()方法也不推荐使用 我该怎么办 这是类代码: public class ReminderService extends WakeReminderIntentService { public ReminderService() { super ("ReminderService"); } @Override void doReminderWork(Intent intent) {

我想为我的应用程序创建通知

它告诉我构造函数通知(,)已弃用

另外,setLateStevenInfo()方法也不推荐使用

我该怎么办

这是类代码:

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

}

}为此使用NotificationCompat.Builder

试试那样的

NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setContentIntent(pendingIntent);