ギャラリーから画像を取得しましたが、それを別のクラスで使用したいと考えています。「uri」でできますか?
Uri selectedImage = data.getData();
String path = selectedImage.getPath();
Intent sintent = new Intent(FromFile.this, OurView.class);
startActivity(sintent);
インテントの作成後にこれを追加します。
sintent.putExtra("image", path);
そして OurView 呼び出しで
String path = getIntent().getStringExtra("image");
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();
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"));