有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Android警报故障

我正在安卓上制作一个简单的提醒应用程序

我有一个日期,比如2011年6月27日(DD-MM-YY),我希望在这个日期(12:01 AM)创建一个警报

我知道这是可能的,但有多容易呢


共 (1) 个答案

  1. # 1 楼答案

    来自google的简单答案:

    Intent intent = new Intent(this, RepeatingAlarmReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, 0);
    
    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), 10 * 1000, pendingIntent);
    Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
    

    如果您需要使用您提到的日期,请创建一个时间对象,使用其构造函数和使用时间设置字段。托米利斯(假);获取报警管理器的正确参数

    问候,, 圣菲