GCM을 수신할 때 저는 서비스단에서 결과를 처리하거든요.
근데 이걸 다음과 같이 하니깐 잘 안되서요.
메인액티비티(MainActivity.class) 호출 -> 자식 액티비티(ChildActivity.class) 호출 (여기서 GCM 수신부 설정)
자식 액티비티에서 GCM 수신 메세지 값을 처리하고 싶은데
서비스단에서 GCM이 수신되니 자동으로 메인액티비티로 돌아가는데
돌아가지 않고 그냥 자식 액티비티에서 값을 받아 TextView에 찍을 수는 없을까요?
[액티비티]
[서비스단]
@Override
public void onMessage(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
String msg = (String) extras.get("msg");
Intent newIntent = new Intent(getBaseContext(), ChildActivity.class);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
newIntent.putExtra("msg", msg);
context.startActivity(newIntent);
}
}
[ChildActivity.class 액티비티]
@Override
protected void onNewIntent(Intent intent) {
String msg = intent.getStringExtra("msg");
Toast.makeText(getApplicationContext(),"[" + from + "]로부터 수신한 메시지 : " + msg, Toast.LENGTH_SHORT).show();
tv.setText(msg);
super.onNewIntent(intent);
}
위에 ChildActivity.class에서 대기 타고 있으면
메인으로 이동해서 깜박 깜박이고 다시 ChildActivity 로 돌아오는데
너무 어색해 보여서요.
조언좀 주시면 너무 감사하겠습니다.^^