如何设置Holiday Reminder应用程序

时间:2013-11-26 06:13:32

标签: android

我是android编程的新手。我想创建一个应用程序,提醒用户显示假期列表,用户通过单击复选框然后按一个按钮来选择要提醒的日期。我已经设置了UI,但是我很难设置警报管理器。有人可以告诉我如何去做这件事,我尝试过很多东西,但似乎都没有。提前谢谢。

我尝试的代码是:                 `

public void sn(int m,int d,int h,int mi,int s,int y,int id)             {         Long time1 = new GregorianCalendar()。getTimeInMillis()+ 20000;

    Calendar c = Calendar.getInstance();
    c.set(Calendar.MONTH, m);
    c.set(Calendar.DAY_OF_MONTH, d);
    c.set(Calendar.HOUR_OF_DAY, h);
    c.set(Calendar.MINUTE, mi);
    c.set(Calendar.SECOND, s);
    c.set(Calendar.YEAR, y);
    long time2 = c.getTimeInMillis();
    long time =time2 ;
    NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notify = new Notification(R.drawable.ic_launcher,"ticker",time);
    Intent i= new Intent(TR.this,TR.class);
    PendingIntent p= PendingIntent.getActivity(TR.this,0,i,0);
    notify.setLatestEventInfo(TR.this, "Title", "contentText", p);
    nm.notify(id,notify);
}

`

每当我尝试这段代码时,它会立即弹出通知,而不是等待设定的时间。它还会在2个地方发出关于弃用的警告 - “新通知(..)”和“notify.setLatestEventInfo(..)”

1 个答案:

答案 0 :(得分:0)

发布链接作为答案,因为它帮助您解决查询。

Link

相关问题