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();
}
}
}
}
精彩评论