Use this for starting the camera app of the phones of tables
// called when the user selects to take a new picture
public void take_Pic(final View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
Then later on in the activity:
/*
* @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
* the result for snapping a new picture or selecting one from the gallery
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
myBitmap = data.getExtras().getParcelable("data");
ImageView photo = (ImageView) findViewById(R.id.pic);
photo.setImageBitmap(myBitmap);// here I am setting the pic to an image view for the user to have a look.
}
}
}
You dont have to make a new class or layout for the `Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); bit. That just opens the camera app of the phone or tablet.
Hope this helps `