How to send image from one activity to another in android?

前端 未结 8 1887
忘掉有多难
忘掉有多难 2020-12-10 08:18

I am having a imageView in one class and on clicking the imageView a dialog box appear which has two option to take a image from camera or open the image gallery of device.

8条回答
  •  误落风尘
    2020-12-10 08:57

    I'm going to show you the best way okay.

    1st) Get and send the image URI

    Uri imageUri = data.getData();
    Intent newIntent = new Intent(Class.this, Class.class);
    newIntent.putExtra(IMAGE_URI_KEY, imageUri);
    startActivity(newIntent);
    

    2nd) Receive the image and how to show it

    receivedImageUri = getIntent().getParcelableExtra(IMAGE_URI_KEY);
    imageView.setImageURI(receivedImageUri);
    

提交回复
热议问题