0

ギャラリーから画像を取得しましたが、それを別のクラスで使用したいと考えています。「uri」でできますか?

Uri  selectedImage = data.getData();
String path = selectedImage.getPath();

Intent sintent = new Intent(FromFile.this, OurView.class);
startActivity(sintent);
4

3 に答える 3

1

インテントの作成後にこれを追加します。

sintent.putExtra("image", path);

そして OurView 呼び出しで

String path = getIntent().getStringExtra("image");
于 2012-07-23T14:01:18.103 に答える
0

1) 次のアクティビティにパスを渡したい場合。これを試して -

Intent sintent = new Intent(FromFile.this, OurView.class);
sintent.putExtra("pathvalue", path);
startActivity(sintent);

nextActivity(OurView.java) で -

String path = getIntent().getStringExtra("image");

2) Uri を次のアクティビティに渡したい場合。これを試して -

Uri  selectedImage = data.getData();
String path = selectedImage.getPath();

Intent intent = new Intent(FromFile.this, OurView.class);
intent.setData(Uri.parse(selectedImage));
startActivity(intent);

nextActivity(OurView.java) で -

Uri selectedImage = getIntent().getData();
于 2012-07-23T14:04:30.467 に答える
0

Uri送信者の のインテントに送信したい画像の を入れることができますActivity。このようなもの:

Intent sintent = new Intent(FromFile.this, OurView.class);
intent.putExtra("selectedImage", selectedImage.toString());
startActivity(sintent);

それを取得するには、Activity呼び出されている で次のコードを使用します。

//Where OurView is assumed to be the class name of your Activity that is being called
Uri selectedImage = Uri.parse(OurView.this.getIntent().getExtras().getString("selectedImage"));
于 2012-07-23T14:01:59.327 に答える