How to pick an image from gallery (SD Card) for my app?

前端 未结 10 1883
Happy的楠姐
Happy的楠姐 2020-11-21 23:40

This question was originally asked for Android 1.6.

I am working on photos options in my app.

I have a button and an ImageView in my Activity. When I click

10条回答
  •  后悔当初
    2020-11-22 00:24

    Do this to launch the gallery and allow the user to pick an image:

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(intent, IMAGE_PICK);
    

    Then in your onActivityResult() use the URI of the image that is returned to set the image on your ImageView.

提交回复
热议问题