안녕하세요.

저는 지금 Service 에서 setRepeating 으로 알람을 등록 후 BroadcastReceiver 를 상속받은 클래스의 onReceive() 에서 Notification 을 보내려고 시도하고 있습니다.

그런데 getSystemService(NOTIFICATION_SERVICE)를 호출하는 부분에서 compile 에러가 뜹니다.

뭐 원인이야 BroadcastReceiver를 상속받은 클래스라 그런거겠지만 그럼 도대체 Alarm을 받은 후 Notification을 보내려면 어떻게 해야할까요??

검색을 해봤는데 어떤분은 Activity를 상속받은 클래스에서 inner class로 BroadcastReceiver를 상속받아서 onReceive()에서 처리하라고 했지만 그렇다면 AndroidManifest.xml 에 <receiver 항목은 어떻게 작성해줘야할까요?



코드는 아래와 같습니다.


AndroidManifest.xml

 <receiver android:name=".NotificationAlarm" />

MyService.java

AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(MyService.this, NotificationAlarm.class);
PendingIntent sender = PendingIntent.getBroadcast(MyService.this, 0, intent, 0);
am.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(), 10000, sender);

NotificationAlarm.java

 public class NotificationAlarm extends BroadcastReceiver {
	NotificationManager mNotiMgr;
	public void onReceive(Context context, Intent intent) {
		Toast.makeText(context, "NotificationAlarm", Toast.LENGTH_SHORT).show();
		mNotiMgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);  // <= Error
	}
}



고수님들의 도움이 절실한 상황입니다.. ㅠㅠ#



공지사항을 다 읽었음 ㅋㅋ