안드로이드 개발 질문/답변
(글 수 45,052)
현재 Active A에서 broadcastreceiver B를 호출 합니다.
아래 부분은 A에서 특정 버튼을 클릭하면 10분마다 B를 호출하도록 한 구문 입니다.
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent;
PendingIntent sender;
intent = new Intent(A.this, B.class);
sender = PendingIntent.getBroadcast(A.this, 0, intent, 0);
am.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(),
TimeRound, sender);
B에서는 Notification을 사용 중입니다.
상태창에 알림 메세지가 오면 알림 메세지를 클릭시 A를 실행하게끔하려고 합니다.
그러나 현재는 아무런 동작을 하지 않는 상태 입니다.
제 생각에는 아래 진하게 표시한 부분에서 설정을 해야 할것 같은데 어떻게 해야 할지 모르겠습니다.
시도한 바로는 아래와 같습니다.
public void onReceive(Context contextArg, Intent intentArg)
{
public NotificationManager nm;
public PendingIntent intentNofoty;
nm = (NotificationManager)contextArg.getSystemService(Context.NOTIFICATION_SERVICE);
intentNofoty = PendingIntent.getActivity(
contextArg, 0,
new Intent(), 0);
Notification notification =
new Notification(android.R.drawable.ic_input_add,
alarmMessageStr, System.currentTimeMillis());
notification.defaults |= Notification.DEFAULT_ALL;
notification.setLatestEventInfo(contextArg,userIdStr, alarmMessageStr, intentNofoty);
nm.notify(BasicNotificationId + WhatDocument, notification);
}//public void onReceive(Context contextArg, Intent intentArg)




Broadcast 하실때는 클래스를 지정하지 마시고... Action으로만 해주세요...