我想要一個的BluetoothSocket傳遞給活動與下面的代碼:
包裹:不能編組值android.bluetooth.BluetoothSocket
Intent intent = new Intent(getActivity(), ChatActivity.class);
Bundle bundle = new Bundle();
ArrayList array = new ArrayList<BluetoothSocket>();
array.add(connectToDevice.getMmSocket());
bundle.putParcelableArrayList("Array", array);
startActivity(intent, bundle);
但是,當我嘗試從活動得到它我要開始用下面的代碼:
Bundle bundle = getIntent().getExtras();
Parcelable[] parceble = bundle.getParcelableArray("Array");
ArrayList<BluetoothSocket> array = new ArrayList<>(parceble.length);
BluetoothSocket socket = array.get(0);
我得到這個錯誤:
java.lang.RuntimeException: Parcel: unable to marshal value [email protected]`
請幫幫我。 在此先感謝。
您無法通過Intent傳遞此類。使服務和綁定活動內 – Selvin
@Selvin \t 我該怎麼做?感謝您的耐心提前 –