Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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
我想使用Android alarm manager每天早上8点运行一个任务_Android_Alarmmanager - Fatal编程技术网

我想使用Android alarm manager每天早上8点运行一个任务

我想使用Android alarm manager每天早上8点运行一个任务,android,alarmmanager,Android,Alarmmanager,我正在使用此代码,但无法执行此操作 此代码中没有错误,但不会触发报警: Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 8); calendar.set(Calendar.MINUTE,0); calendar.set(Calendar.SECOND, 0); PendingIntent pi = PendingIntent.getServi

我正在使用此代码,但无法执行此操作
此代码中没有错误,但不会触发报警:

    Calendar calendar = Calendar.getInstance();

    calendar.set(Calendar.HOUR_OF_DAY, 8); 
    calendar.set(Calendar.MINUTE,0);
    calendar.set(Calendar.SECOND, 0);

    PendingIntent pi = PendingIntent.getService(this, 0,
            new Intent(this, Home.class),PendingIntent.FLAG_UPDATE_CURRENT);

    AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);

    am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
            AlarmManager.INTERVAL_DAY, pi);

你在这里的意图中提到的Home类到底是什么?好吧,我知道了,所以应该有receiver类吧..?我首先要问Home是什么,因为这里的代码中没有详细说明。请看下面的答案:,它正在讨论使用AlarmManager自动发送sms,但会快速查看计划每天执行的任务的步骤和可能的陷阱。