I am new to android and am creating a small application that takes pictures from the camera and saves it in the gallery.
Here is the function that captures the image.
private void onCaptureImageResult(Intent data) { Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); thumbnail.compress(Bitmap.CompressFormat.JPEG, 90, bytes); File destination = new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis() + ".jpg"); FileOutputStream fo; try { destination.createNewFile(); fo = new FileOutputStream(destination); fo.write(bytes.toByteArray()); fo.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
This is activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/LinearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="10dp" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="5dp" > <Button android:id="@+id/btnSelectPhoto" android:background="#149F82" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Select Photo" /> </LinearLayout> </LinearLayout>
What I want to do when capturing an image, I want to display the image on a different activity (page), but not on the same action that has a button for capturing the image. How to do it.
Thank you in advance
source share