- i also want to know how to directly send an image to another activity.. your help will be appreciated..!
发布于 2017-03-05 01:30:38
假设您有一个调用的startActivityForResult
方法,当用户选择一个图像时,您的onActivityResult
方法将调用,然后您有如下所示:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri uri = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
}
您可以通过以下方式轻松地将URI发送到下一个活动:
startActivity( new Intent( MainActivity.this,imageActivity.class).putExtra("image",uri));
https://stackoverflow.com/questions/42606580
复制相似问题