开发者

How to access gallery -> Camera Media videos and display it in List on button Click?

开发者 https://www.devze.com 2022-12-31 08:23 出处:网络
i am beginner in Android app development i am开发者_Python百科 working on a app which lists the videos and imagesand uploads them from android phone to the windows server,

i am beginner in Android app development i am开发者_Python百科 working on a app which lists the videos and images and uploads them from android phone to the windows server,

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

help me out with the listing images and videos........................


within 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();
            }
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消