开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜