How to set chosen image from gallery to linear layout using intent?

rs11

Source Code for get image from gallery and set it to image view and i want to pass the selected image in another activity and set it to linear layout.

 private void galleryIntent() {
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);//
        startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
    }

    private void onSelectFromGalleryResult(Intent data) {
        bitmap = null;
        if (data != null) {
            filePath = data.getData();
            try {
                bitmap = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), data.getData());
                System.out.println("bitmap is :" +bitmap);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        set.setImageBitmap(bitmap);

    }
PRATEEK BHARDWAJ
private static int RESULT_LOAD_IMAGE = 1;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button buttonLoadImage = (Button) findViewById(R.id.buttonLoadPicture);
    buttonLoadImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {

            Intent i = new Intent(
                    Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

            startActivityForResult(i, RESULT_LOAD_IMAGE);
        }
    });
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
        Uri selectedImage = data.getData();
        String[] filePathColumn = { MediaStore.Images.Media.DATA };

        Cursor cursor = getContentResolver().query(selectedImage,
                filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String picturePath = cursor.getString(columnIndex);
        cursor.close();


         Intent i=new Intent(this,NextActivity.class);
    i.putExtra("path",picturePath);
    startActivity(i);



    }


}

NextActivity File :-

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

        LinearLayout imageView = (LinearLayout) findViewById(R.id.imgView);
        Bitmap bmImg = BitmapFactory.decodeFile(picturePath);
        BitmapDrawable background = new BitmapDrawable(bmImg);
        imageView.setBackgroundDrawable(background);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to set background image in Linear layout dynamically using Parser in android

From Dev

How to set image for imageview and linear layout from Drawable path in android

From Dev

How to set the background of a layout with a photo from gallery?

From Dev

Image rotated when chosen from gallery

From Dev

how to view video in activity that is chosen from the gallery

From Dev

How to save a layout as a image in gallery?

From Dev

How to set a linear layout of buttons at the top of an image (layouts in android)?

From Dev

The code does not store image from layout in gallery

From Dev

Set image to the listview from intent

From Dev

how to get image from gallery

From Dev

how to resize image from gallery

From Dev

how to get image from gallery

From Dev

Save Image (took with Camera Intent) from ImageView to device (Gallery/SdCard)

From Dev

how to set one linear layout below another linear layout in android

From Dev

how to set one linear layout below another linear layout in android

From Dev

How can i set an image taken from the Camera intent into a ImageView?

From Dev

Image from Gallery is not being set to imageview

From Dev

Picking image from gallery and set to imageview

From Dev

Set ImageView with selected Image from Camera or Gallery

From Dev

Get image from gallery to set in imageview in fragment?

From Dev

Android - Load image from gallery and set as background

From Dev

Code to set any image as a wallpaper from the gallery

From Dev

set phone background image from gallery

From Dev

Set image in imageview from gallery and save it?

From Dev

Android gallery intent: How can i get and set original cropped image with full size and good quality instead of thumbnail?

From Dev

Linear Partitioning, Perfect Image Gallery

From Dev

Linear Partitioning, Perfect Image Gallery

From Dev

How to center fit image in linear layout?

From Dev

How to set the border color for linear layout

Related Related

  1. 1

    how to set background image in Linear layout dynamically using Parser in android

  2. 2

    How to set image for imageview and linear layout from Drawable path in android

  3. 3

    How to set the background of a layout with a photo from gallery?

  4. 4

    Image rotated when chosen from gallery

  5. 5

    how to view video in activity that is chosen from the gallery

  6. 6

    How to save a layout as a image in gallery?

  7. 7

    How to set a linear layout of buttons at the top of an image (layouts in android)?

  8. 8

    The code does not store image from layout in gallery

  9. 9

    Set image to the listview from intent

  10. 10

    how to get image from gallery

  11. 11

    how to resize image from gallery

  12. 12

    how to get image from gallery

  13. 13

    Save Image (took with Camera Intent) from ImageView to device (Gallery/SdCard)

  14. 14

    how to set one linear layout below another linear layout in android

  15. 15

    how to set one linear layout below another linear layout in android

  16. 16

    How can i set an image taken from the Camera intent into a ImageView?

  17. 17

    Image from Gallery is not being set to imageview

  18. 18

    Picking image from gallery and set to imageview

  19. 19

    Set ImageView with selected Image from Camera or Gallery

  20. 20

    Get image from gallery to set in imageview in fragment?

  21. 21

    Android - Load image from gallery and set as background

  22. 22

    Code to set any image as a wallpaper from the gallery

  23. 23

    set phone background image from gallery

  24. 24

    Set image in imageview from gallery and save it?

  25. 25

    Android gallery intent: How can i get and set original cropped image with full size and good quality instead of thumbnail?

  26. 26

    Linear Partitioning, Perfect Image Gallery

  27. 27

    Linear Partitioning, Perfect Image Gallery

  28. 28

    How to center fit image in linear layout?

  29. 29

    How to set the border color for linear layout

HotTag

Archive