0
이 스레드는 Android: how to use data passed from parent activity in a sub activity?이고이 방법에 대한 준비가 완료되었지만 구형인지 궁금합니다. 안드로이드는 그 이후로 많은 발전을 이루었고 나는 이것을 잘못하고 싶지 않습니다.하위 액티비티에서 상위 액티비티로 데이터 전달
여전히 사용해야하는 방법입니까?
이 스레드는 Android: how to use data passed from parent activity in a sub activity?이고이 방법에 대한 준비가 완료되었지만 구형인지 궁금합니다. 안드로이드는 그 이후로 많은 발전을 이루었고 나는 이것을 잘못하고 싶지 않습니다.하위 액티비티에서 상위 액티비티로 데이터 전달
여전히 사용해야하는 방법입니까?
이 방법은 완벽하게 잘되어 오늘날에도 여전히 사용됩니다. Bundle을 사용하여 데이터를 전달할 수있는 또 다른 방법이 있습니다.
Intent intent = new Intent(ActivityA.this, ActivityB.class);
Bundle b = new Bundle();
b.putString("name", "abcd");
b.putInt("value", 666);
//Add the set of extended data to the intent and start it
intent.putExtras(b);
startActivity(intent);
그리고 다른 활동 사용에 다음과 같이 번들을 사용할 수 있습니다
Bundle b = getIntent().getExtras();
int value = b.getInt("value", 0);
String name = b.getString("name");