728x90 전달2 안드로이드 객체 전달 Parcelabel Intent 를 통해 객체를 전달 할 때는 객체 직렬화를 해야 하는데 안드로이드는 Parcelable 인터페이스를 사용한다. Parcelable 인터페이스는 전달 받은 쪽에서 객체를 복원할 때 필요한 정보를 가진 부분을 의미한다. 메인 액티비티 package com.example.activityobject import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_second.* cl.. 2022. 6. 9. 안드로이드 activity 데이터 전달 intent에 데이터 셋팅하기 Activity를 실행하기 위해 사용하는 Intent 객체에 데이터를 저장할 수 있다. putExtra 메서드를 통해 데이터 저장이 가능하며 데이터가 저장된 Intent는 실행되는 Activity까지 전달된다. 이를 통해 Intent에 저장된 데이터를 추출할 수 있다. Intent는 Activity를 종료하고 돌아갈 때도 전달 할 수 있다. intent에 데이터 가져오기 전달된 Intent 에 저장된 데이터는 getXXXExtra 메서드를 통해 추출할 수 있다. 이 메서드는 자료형 별로 이름이 다르므로 자료형에 맞는 메서드를 사용해야 한다 메인 액티비티 package com.example.activitydata import android.content.Intent impor.. 2022. 6. 9. 이전 1 다음 728x90