다음과 같은 문제가 있습니다. 나는 2 개의 클래스가 있습니다. 1은 AlarmService이고 다른 하나는 BroadcastReceiver를 확장 한 TimeAlarm입니다. 앱은 다음을 수행해야합니다. Logcat에서도 환경 설정 (이미 수행 한 작업 ...)에서 지정된 시간까지 새 알람을 생성해야합니다. 그러면 알람이 트리거되는 방식을 볼 수 있습니다. 그러나 문제는 표시해야하는 알림이 StatusBar에 표시되지 않는다는 것입니다.브로드 캐스트 수신자가 트리거를 수신하지 않음 알람
의 AndroidManifest.xml :
<receiver android:name="com.ikalma.alarmmanager.TimeAlarm">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
AlarmService.java : 여기
내가 이것을 위해 모두 코드입니다private Context context;
private PendingIntent mAlarmSender;
public AlarmService(Context context) {
this.context = context;
Intent notifyIntent = new Intent(Intent.ACTION_MAIN);
notifyIntent.setClass(context, myActivity.class);
mAlarmSender = PendingIntent.getBroadcast(context, 0, notifyIntent, 0);
}
public void startAlarm(int stunde, int minute) {
Calendar updateTime = Calendar.getInstance();
updateTime.set(Calendar.HOUR_OF_DAY, stunde);
updateTime.set(Calendar.MINUTE, minute);
updateTime.set(Calendar.SECOND, 00);
AlarmManager am = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(),
AlarmManager.INTERVAL_DAY, mAlarmSender);
}
TimeAlarm.java :
@Override
public void onReceive(Context context, Intent intent) {
Log.e("TEST", "onReceive() called...");
}
수신기 매니페스트의 태그는 태그 내부에 있으므로 문제가되지 않아야합니다. 문제는 장치를 다시 시작하면 호출된다는 것입니다. 알람이 울리면 안됩니다. 그러나 알람이 발생하면 onReceive() 메서드를 호출해야합니다. 그렇습니까?
도움 주셔서 감사합니다.
감사합니다. 나는 이것을 Manifest에 추가했지만 아무 것도 변경하지 않았다. ( 아마도, android.intent.action.MAIN으로 선언 된 SplashScreen이 있지만 SplashScreen이 알람을 생성하지 않을 수도있다. – user754730
잘 의도의 동작이 인 텐트 필터에 명시된 동작과 동일한 경우에만 동작을 다른 것으로 변경할 수 있습니다. 또한 notifyIntent.setClass (context, myActivity.class)를 제거하려고 할 수 있습니다. 특정 활동으로 보내지는 않지만 방송 수신자가 수신해야하는 브로드 캐스트를 사용하고 있습니다. – senola
notifyIntent의 setClass를 제거하는 것이 전부였습니다 ... 물론 설정되지 않은 인 텐트 필터 액션 감사합니다. 당신의 도움! – user754730