Reputation: 1362
I have custom Listview
. Inside it has one Button
and ImageView
.
on Button click Camera will open.(Camera Intent fired).
I want that captured Image (you also call as Bitmap) onto ImageView
which is also a ListItem.
that means when i capture image and press Done button of camera then my imageview have to set that image.
How can i do this?
Upvotes: 0
Views: 108
Reputation: 1188
private static int FILE_SELECT_CODE_1 = 0;
function intentCamera(){
Intent i = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, FILE_SELECT_CODE_1);
}
private String getLastImagePath() {
final String[] imageColumns = { MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATA };
final String imageOrderBy = MediaStore.Images.Media._ID + " DESC";
Cursor imageCursor = managedQuery(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, imageColumns,
null, null, imageOrderBy);
if (imageCursor.moveToFirst()) {
//int id = imageCursor.getInt(imageCursor.getColumnIndex(MediaStore.Images.Media._ID));
String fullPath = imageCursor.getString(imageCursor
.getColumnIndex(MediaStore.Images.Media.DATA));
// Log.d(TAG, "getLastImageId::id " + id);
// Log.d(TAG, "getLastImageId::path " + fullPath);
imageCursor.close();
return fullPath;
} else {
return "";
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FILE_SELECT_CODE_1 && resultCode == RESULT_OK){
String lastImagePath = getLastImagePath();
File fileImage = new File(lastImagePath);
Uri u = Uri.fromFile(fileImage);
//now you can set the image example:
ImageView img = new ImageView(this);
img.setImageURI(u);
}
}
Upvotes: 0
Reputation: 1971
Follow the below steps,
onActivityResult
of you activity.Upvotes: 1