죄송합니다 이전 대답하지만 난 모든 곳에서 보았다하지만 난 자동 오전 9 일상에서 알림을 화재 알람 관리기를 사용하고잘못된 시간에 응답 알람 관리기
적절한 솔루션을하지 않았지만, 만약 내가 그것을 실행하려고하면 에뮬레이터는 즉시 실행되며 매 30 분마다 (정확히는 31-32 분) 실행됩니다.
왜 그런가? 도움을 주셨습니다.
코드는 다음과 같습니다 :
public class Home extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bsheet);
notificationAlert(savedInstanceState);
}
private void notificationAlert(Bundle savedInstanceState) {
AlarmManager manager;
PendingIntent pendingIntent;
Intent intent=new Intent(Home.this, Notify.class);
manager=(AlarmManager)getSystemService(ALARM_SERVICE);
pendingIntent=PendingIntent.getService(Home.this,
0, intent, 0);
GregorianCalendar gcal = new GregorianCalendar();
gcal.set(Calendar.HOUR_OF_DAY, 9);
gcal.set(Calendar.MINUTE, 0);
gcal.set(Calendar.SECOND, 0);
gcal.set(Calendar.MILLISECOND, 0);
long initTime = gcal.getTimeInMillis();
manager.setRepeating(AlarmManager.RTC_WAKEUP, initTime,
24*60*60*1000, pendingIntent);
}
}
환호,
편집 : 내 의도 앱이 설치되면, 그것은 오전 9에서이 경보를 발생한다는 것입니다. 나는 알람을 onCreate에 넣었습니다. 알람이 앱을 시작할 때마다 생성되고, 앱을 숨길 때 이상한 일이 일어나는지 확실하지 않습니다. 다시 통찰력을 얻었습니다!
감사합니다. 안타깝게도, 앱을 시작할 때마다로드됩니다 ... 나는 몇 가지 수정안을 작성하고 곧바로 완전한 해결책을 보여줄 것입니다. –
다음에 시간을 비교하고 알람을 시작하십시오. –
편집을 참조하십시오 ... 비교 비트를 수행하는 방법을 모르십니까? –