私はBluetoothデバイスオブジェクトを作成する新しいアクティビティを作成します。私はonActivityResult()メソッドを使ってこれを返す必要があるとき、私は問題があります。onActivityResultでオブジェクトを取得
子アクティビティ
Intent intent = new Intent();
intent.putExtra("BluetoothDevice", DeviceArrayList.get(arg2));
setResult(Activity.RESULT_OK, intent);
finish();
DeviceArrayList.get(arg2)はデバイス・オブジェクトです。私はbtDeviceでオブジェクトを取得することができます
親アクティビティ
BluetoothDevice btDevice;
...
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if(resultCode == Activity.RESULT_OK){
btDevice = data.getExtras("BluetoothDevice");
}
if (resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(this, "Resultado cancelado", Toast.LENGTH_SHORT)
.show();
}
}
}//onActivityResult
?
ホセMのようにそれをキャスト: 詳細はアンドロイドのドキュメントを見てくださいBluetoothDeviceがSerilizableまたはParceableの仲間であるです? SerializableまたはParceableオブジェクトのみをインテントで渡すことができます:) –
mm ..わかりません:(この場合、私はそれをシリアル化できますか?) –
android.bluetooth.BluetoothDeviceを使用している場合、パーセルブルが拡張されていますintent.putParcelable( "key"、object) – darwin