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


Google Developers : BluetoothDevice

블로그 이미지

NCookie

,