Serializable 을 implements 해서 BluetoothDevice 객체를 Intent에 넣어서 전달하려고 했는데, 막상 받아보니 null 값이 들어있었다.
그래서 찾아보니, BluetoothDevice 클래스 선언 단계에서 Parcelable 을 implements 하였고, 필요한 함수들도 이미 구현되어 있다고 한다.
그래서 Parcelabe을 implements 하거나 그에 따라 필요한 함수들도 따로 구현할 필요가 없다.
그냥 값을 넘길 때
intent.putExtra(intent_key, mSelectedDevice);
startActivity(intent);
하고, 값을 받으려면
Intent intent = getIntent();
BluetoothDevice bluetoothDevice = intent.getExtras().getParcelable(intent_key);
이렇게 하면 된다. 엄청 편하다.
참고
Passing BluetoothDevice Object to Another Activity though Intent
'안드로이드' 카테고리의 다른 글
current activity 가져오기 (0) | 2018.01.02 |
---|---|
[안드로이드] Service에 대하여 (0) | 2017.12.22 |
안드로이드 이미지 여백 (0) | 2017.12.05 |
안드로이드 플랫폼 아키텍쳐 (0) | 2017.11.30 |
안드로이드 java.lang.NoSuchMethodError: No static method getFont (0) | 2017.11.28 |