특정 시간에 알람 관리자를 사용하여

Abhinav :

나는 알람 관리기의 존재 세트에서 ~ 오후 11시 59 분 IST에서 코드 블록을 실행하는 데 필요합니다.

누군가가 나 안드로이드에 알람 관리기를 사용하는 방법에 대한 샘플 코드를 게재 할 수 있습니까?

나는 며칠 동안 몇 가지 코드로 주위를 연주하고 그냥 작동하지 않습니다.

Sebsir :

여기를 사용하는 샘플 코드입니다 AlarmManager, 당신은 당신의 필요에 따라 날짜와 시간을 변경해야합니다. 나는 23:59에 오늘 넣어

// Pending intent to be fired when alarm occurrs. In this case, open the AlarmActivity
Intent intent = new Intent(getApplicationContext(), AlarmActivity.class);
PendingIntent alarmIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);

// Set the alarm for today at 23:59
calendar = Calendar.getInstance(TimeZone.getTimeZone("IST"));
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);

AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP,
        calendar.getTimeInMillis(),
        alarmIntent);

당신이 AlarmActivity 당신에게 논리를 만들 필요가 있도록 주어진 날짜와 시간에 텐트가 발사됩니다. 또한 서비스를 시작 의도를 변경하거나 브로드 캐스트 메시지를 발사 할 수

추천

출처http://10.200.1.11:23101/article/api/json?id=410169&siteId=1