I'm trying to upload a camera to take a picture from my Android application,
my Photos.java
private Uri imageUri; public void takePhoto(View view) { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); imageUri = Uri.fromFile(photo); startActivityForResult(intent, TAKE_PICTURE); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case TAKE_PICTURE: if (resultCode == Activity.RESULT_OK) { Uri selectedImage = imageUri; getContentResolver().notifyChange(selectedImage, null); ImageView imageView = (ImageView) findViewById(R.id.ImageView); ContentResolver cr = getContentResolver(); Bitmap bitmap; try { bitmap = android.provider.MediaStore.Images.Media .getBitmap(cr, selectedImage); imageView.setImageBitmap(bitmap); Toast.makeText(this, selectedImage.toString(), Toast.LENGTH_LONG).show(); } catch (Exception e) { Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT) .show(); Log.e("Camera", e.toString()); } } }
and it works great. But his section of the layout, to name this intention, with which I struggle.
I created a button to load the camera
<Button android:id="@+id/takePhoto" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="41dp" android:onClick="takePhoto" android:text="@string/Photos_Button1" />
but now I need to have a section to show the image I took. How to do it?
source share