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

前端 未结 10 1870
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:03

    You have to start the gallery intent for a result.

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

    Then in onActivityForResult, call intent.getData() to get the Uri of the Image. Then you need to get the Image from the ContentProvider.

提交回复
热议问题