안드로이드 개발 질문/답변
(글 수 45,052)
a 클래스의 액티비티에서 블루투스 소켓 연결을 하고 연결을 유지한채 비동기적으로 메시지를 받습니다.
그리고 b 클래스가 실행이 되고 b클래스에서 a클래스의 핸들러의 메시지를 동일하게, 비동기적으로 받고 싶은데요.
어떤식으로 구현하면 되는지 모르겠네요....
방법이 없는 것인가요????
꼭 이 방법이 아니더라도 구현을 하는 다른 방법이 있다면 어떤 것이 있는지 궁금합니다.......
고수님들의 많은 답변 바랍니다.
2011.07.20 16:20:23
class a에서 비동기식으로 메세지를 받는다면 그 메시지 받는 순간에
Intent intent = new Intent(a.this, b.class);
intent.putExtra("msg", string변수);
startActivity(intent);
로 B class로 intent를 넘기구(이 순간 B class로 넘어가니 onCreate나 OnResume등과 같은 함수를 이용하심 됩니다)
B class의 OnCreate나 OnResume등을 이용하여
Intent intent = getIntent();
Bundle extra = intent.getExtras();
string msg = extra.getString("msg");
를 하시면 될것같네요~^^




단순히 문자 메세지를 넘기시는 거면
class a
Intent intent = new Intent(a.this, b.class);
intent.putExtra("msg", string변수);
startActivity(intent);
class b
Intent intent = getIntent();
Bundle extra = intent.getExtras();
string msg = extra.getString("msg");
다음과 같이 하시면 class a의 메세지를 특정 이벤트나 함수를 기점으로 class b에 전송할 수 있습니다