OnNewIntent()

Jang Seok Woo·2021년 7월 13일
0

실무

목록 보기
40/136

OnNewIntent에 관해 정리해 보겠습니다.

화면 전환을 하실떄

Intent intent = new Intent(this , MainActivity.class);
startActivity(intent);

위와같은 기본 화면 전환 인텐트입니다.

기본적인 Activity 생명주기에 따라, OnCreate -> OnResume -> .... 이런식으로 시작이되죠?

위와같이 foreground 상태(Bactivity 가보여지는 화면에서)

다시한번 불러줍니다.

Intent intent = new Intent(this , MainActivity.class);
intent.putExtra("test","test");
startActivity(intent);

현재 B화면에서 B를 다시불르게된다면...

여기서 onNewIntent() 가발생하게됩니다.

생명주기는 onNewIntent -> OnResume -> ..... 이런식으로

OnCreate는 불려지지 않고 OnNewIntent 가 불려집니다.

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
    //// TODO: 2017-07-03
    String test = intent.getStringExtra("test");

    Log.d("테스트",test);
}

읽어주셔서 감사합니당 :)

profile
https://github.com/jsw4215

0개의 댓글