마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 브로드캐스트 값 전달 안되는 문제

0 추천
  Intent intent = new Intent(English_Service.this, Timer_English.class);
            intent.setAction("sample");
            intent.putExtra("timer_real", hms);
            sendBroadcast(intent);
public void onResume() {
        super.onResume();
        IntentFilter filter = new IntentFilter();
        filter.addAction("sample");
        registerReceiver(sn_english, filter);
    }

    public void onPause() {
        super.onPause();
        unregisterReceiver(sn_english);
    }

    BroadcastReceiver sn_english= new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {

            intent = getIntent();
            String timer_real = intent.getStringExtra("timer_real");
            textTimer.setText(timer_real);

        }
    };

이런식으로 서비스에서 보내고 다른 액티비티에서 받게 했는데 값 전달이 전혀 안되더라구요..

혹시 문제 있는 부분이 있나요..? 계속 죄송합니다..

KRJ (820 포인트) 님이 2015년 2월 5일 질문
KRJ님이 2015년 2월 5일 수정

2개의 답변

0 추천
 
채택된 답변
Intent intent = new Intent(English_Service.this, Timer_English.class);
안에 내용을 빼고
 
Intent intent = new Intent();
로 하세요
 
alkyne (22,960 포인트) 님이 2015년 2월 5일 답변
KRJ님이 2015년 2월 6일 채택됨
바꿔봤는데 별 반응이 없네요..ㅠㅠ
onReceive안에 intent = getIntent();도 빼세요
오!! 드디어 되네요 ㅠㅠ 감사합니당
정말 죄송한데.. 혹시 한 액티비티에서 2개의 BR을 수신하려면 저 상태에서 어떤식으로 수정을 해줘야 되나요?
setAction에 들어가는 문구를 바꾸면 됩니다
0 추천
'sample' 로 매니페스트에 정의 해야합니다. 코드로 정의하거나요.
익명사용자 님이 2015년 2월 5일 답변
코드로 정의하는게 제가 올린 코드중에 아래 것으로으로 되는게 아닌가요..?
...