Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3871282
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:48:32+00:00 2026-05-19T21:48:32+00:00

Writing an app which takes a picture from the camera and retrieves it as

  • 0

Writing an app which takes a picture from the camera and retrieves it as a bitmap. I then write this file to the disk and attempt to send the picture as an email, in the gmail app it says there is an attachment however when I receive the email no file is attached. Here are the two appropriate methods I am trying to get working.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    if (requestCode == CAMERA_PIC_REQUEST) {  
    thumbnail = (Bitmap) data.getExtras().get("data");  
    ImageView image = (ImageView) findViewById(R.id.photoResultView);  
    image.setImageBitmap(thumbnail);


    try {
            pic = new File("pic");

        FileOutputStream out = new FileOutputStream(pic);
        thumbnail.compress(CompressFormat.PNG, 100, out);
        out.flush();
        out.close();

    }
    catch (java.io.FileNotFoundException e) {
        // that's OK, we probably haven't created it yet
    }
    catch (Throwable t) {
        Toast
            .makeText(this, "Exception: "+t.toString(), Toast.LENGTH_LONG)
            .show();

    }   
    sendPictureButton.setVisibility(Button.VISIBLE);
    }  
}
private OnClickListener sendPictureButtonListener = new OnClickListener() {

    @Override
    public void onClick(View arg0){

        Intent i = new Intent(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_EMAIL, new String[]{"fakeaddress@hello.edu"});
        i.putExtra(Intent.EXTRA_SUBJECT,"On The Job");
        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(pic));

        i.setType("image/png");
        startActivity(Intent.createChooser(i,"Share you on the jobing"));

    }
    };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T21:48:33+00:00Added an answer on May 19, 2026 at 9:48 pm

    First needed to access the SD Card, then find it and write to it and grab the URI of the file.

    Here is the functioning code:

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
        if (requestCode == CAMERA_PIC_REQUEST) {  
        thumbnail = (Bitmap) data.getExtras().get("data");  
        ImageView image = (ImageView) findViewById(R.id.photoResultView);  
        image.setImageBitmap(thumbnail);
    
    
            try {
                File root = Environment.getExternalStorageDirectory();
                if (root.canWrite()){
                    pic = new File(root, "pic.png");
                    FileOutputStream out = new FileOutputStream(pic);
                    thumbnail.compress(CompressFormat.PNG, 100, out);
                    out.flush();
                    out.close();
                }
            } catch (IOException e) {
                Log.e("BROKEN", "Could not write file " + e.getMessage());
            }   
        sendPictureButton.setVisibility(Button.VISIBLE);
        }  
    }  
    
    
    private OnClickListener takePictureButtonListener = new OnClickListener() {
    
        @Override
        public void onClick(View arg0){
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);  
    
        }
        };
    
        private OnClickListener sendPictureButtonListener = new OnClickListener() {
    
        @Override
        public void onClick(View arg0){
    
            Intent i = new Intent(Intent.ACTION_SEND);
            i.putExtra(Intent.EXTRA_EMAIL, new String[]{"fake@fake.edu"});
            i.putExtra(Intent.EXTRA_SUBJECT,"On The Job");
            //Log.d("URI@!@#!#!@##!", Uri.fromFile(pic).toString() + "   " + pic.exists());
            i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(pic));
    
            i.setType("image/png");
            startActivity(Intent.createChooser(i,"Share you on the jobing"));
        }
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Writing an app which takes the preview frames from camera does some transformation to
I am writing an iPhone app which takes video from the camera, runs it
I'm writing a small App in which i read some text from to console,
I'm writing an app that takes some massive amounts of texts as input which
I'm writing an app in which the user takes a photo of them self,
I've an app that takes a camera picture and saves on sdcard as jpeg.
I am writing an app that uses the camera intent to take a picture.
I'm writing an app which plays host to a series of plug-ins. Those plug-ins
I am writing an app which needs to have both the traditional form of
I am writing an app which is going to be displaying images found on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.