[英]Pass image picked from gallery to other intent
I want to pass image picked from gallery to other intent. 我想将从图库中选取的图像传递给其他意图。 But when I click upload button and then select image from gallery it shows me the same activity.
但是,当我单击上载按钮,然后从图库中选择图像时,它向我显示了相同的活动。 As if i am stuck on that activity.
好像我在从事这项活动。 Can anyone help?????
谁能帮忙????? This is my code..
这是我的代码。
if (resultCode == RESULT_OK && data != null) {
Uri photouri = data.getData();
if (photouri != null) {
try {
String[] filePath = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(photouri,
filePath, null, null, null);
cursor.moveToFirst();
int ColIndex = cursor.getColumnIndex(filePath[0]);
String FilePath = cursor.getString(ColIndex);
cursor.close();
photo = BitmapFactory.decodeFile(FilePath);
Intent intent2 = new Intent(Activity1.this, Activity2.class);
intent2.putExtra("BitmapImage", photo);
startActivity(intent2);
} catch (Exception e) {
}
}
Code in Activity2 活动2中的代码
pic1= (Bitmap) this.getIntent().getParcelableExtra("BitmapImage");
img.setImageBitmap(pic1);
I am doing this in my app but instead of calling decodeFile in first activity, I just passed the actual filename (path) selected from the gallery and let the second activity decode it. 我正在我的应用程序中执行此操作,但我没有传递第一个活动中的deleteFile,而是传递了从图库中选择的实际文件名(路径),然后让第二个活动对其进行解码。
Intent intent2 = new Intent(Activity1.this,Activity2.class);
Activity2.intent2.putString("BitmapFilename",FilePath);
startActivity(intent2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.