How to access the gallery & # 8594; Camera videos and display them in the list on the button Press?

I am new to Android app development. I am working on an application that lists videos and images and downloads from an Android phone to a Windows server.

Listvideo button = (button) findViewById (R.id.Listvideo); Listvideo.setOnClickListener (this);

help me with a list of images and videos ........................

+3
source share
2 answers

in your OnClick method:

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);

onActivityResult method:

protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    if (resultCode == RESULT_OK) {
        Uri photoUri = intent.getData();

        if (photoUri != null) {
            try {
                Bitmap bitmap = MediaStore.Images.Media.getBitmap(this
                    .getContentResolver(), photoUri);
                your_imgv.setImageBitmap(bitmap);
                profilePicPath = photoUri.toString();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
+1
source

Source: https://habr.com/ru/post/1746147/


All Articles