안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요!
서비스에서 앱과 위젯에 동시에 intent 를 보내주고 싶은데..
Intent intent = new Intent(TESTService.this, TESTProvide.class);
Intent intent2 = new Intent(TESTService.this, TESTActivity.class);
이렇게 해서,
sendBroadcast(intent);
sendBroadcast(intent2);
이렇게, 서비스에서 각각 지정해서 보내줘야 하나요? 아니면, 어차피 같은 패키지를 쓰는 애들이니..
new Intent(this, 패키지); 여기에다가 하나의 패키지를 쓰는 애들한테 보내주는 방법은 없나요?
2개를 보낼려니 뭔가 좀 거슬리네요..




Intent intent = new Intent();
intent.setAction([액션명]);
sendBroadcast(intent);
___________________________
위 처럼 component형식으로 보내지 말고,
action을 사용해 보내고,
받는쪽은 같은 action으로 필터하면 됩니다.
참고로, activity는 receiver가 아니므로, activity안에 registerReceiver로 리시버를 등록해 사용할 수 있습니다.