これが私が渡しているものです。pictureFile
ですFile
Intent intent = new Intent (context, ShowPicActivity.class);
intent.putExtra("picture", pictureFile);
次のアクティビティでは、どのゲッターを使用してそれを取得しますか?
Intent intent = getIntent();
……?
これが私が渡しているものです。pictureFile
ですFile
Intent intent = new Intent (context, ShowPicActivity.class);
intent.putExtra("picture", pictureFile);
次のアクティビティでは、どのゲッターを使用してそれを取得しますか?
Intent intent = getIntent();
……?
File はserializableを実装します (インテントを介してオブジェクトを送信するために最初に確認すること) ( source )
結果のオブジェクトを次のように File にキャストするだけです。
File pictureFile = (File)getIntent.getExtras().get("picture");
大丈夫です。(シリアル化可能なオブジェクトを必要とする「オブジェクト」のゲッターを使用して返します。キャストで十分です。)
次のことを試してください。
YourPictureClass picture = (YourPictureClass)getIntent().getExtras().get("picture");
を呼び出すと、 のインスタンスが取得getExtras()
されます。
通常のクラスでは、呼び出し元に渡すすべてを読み取ることができます。あなたがしなければならない唯一のことは、あなたのオブジェクトがインスタンスであることを解析することです。
Intent
Bundle
get()
Bundle
Object
Intent
class