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 8000431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:47:34+00:00 2026-06-04T15:47:34+00:00

I am trying to create an App that takes a picture when a button

  • 0

I am trying to create an App that takes a picture when a button is pressed and then attaches it to email when a send button is pressed. The code I have shows that the picture is attached to the email, but the attachment is not sent when I check the email I sent it to.The image is not saved in the SD card too.

I call the initialize function in my onCreate() to initialize variable.Also I dont know where to put the SaveImage() function which has to save the image once it’s taken. I put it in the onActivityResult() but does not work.
Thanks in advance!

private void initialize() {
    // TODO Auto-generated method stub
    camera = (Button) findViewById(R.id.Picture);
    sendEmail = (Button) findViewById(R.id.SendMessage);
    iv = (ImageView) findViewById(R.id.ImageReturn);
    MessageTyped = (EditText) findViewById(R.id.MessageField);
    sendEmail.setOnClickListener(this);
    camera.setOnClickListener(this);

    pngDir = new File(Environment.getExternalStorageDirectory(),
    // Loose convention inferred from app examples
            "My Images");

    if (!pngDir.exists())
        pngDir.mkdirs();

}

@Override
public void onClick(View v) {

    // TODO Auto-generated method stub

    switch (v.getId()) {

    case R.id.Picture:
        i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        SaveImage();//<------------------WHERE DOES THIS GO?

        startActivityForResult(i, cameraData);

        break;

    case R.id.SendMessage:

        EditTextToString();

        EmailIntent = new Intent(android.content.Intent.ACTION_SEND);

        EmailIntent.putExtra(Intent.EXTRA_EMAIL,
                new String[] { "bipush.osti@gmail.com" });
        EmailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                MessageToBeReceived);

        // EmailIntent.setType("message/rfc822");
        EmailIntent.setType("image/jpeg");
        EmailIntent.putExtra(Intent.EXTRA_STREAM, pngUri);

        startActivity(Intent.createChooser(EmailIntent,
                "Choose an Email client :"));
        break;

    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        bmp = (Bitmap) extras.get("data");
        iv.setImageBitmap(bmp);

    }
}

private void EditTextToString() {
    MessageToBeReceived = MessageTyped.getText().toString();
}

private void SaveImage() {

    File pngFile = new File(pngDir, "jetsam.jpeg");
    // Save file encoded as PNG
    pngUri = Uri.fromFile(pngFile);

}
  • 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-06-04T15:47:36+00:00Added an answer on June 4, 2026 at 3:47 pm

    See documentation of ACTION_IMAGE_CAPTURE! If you didn’t gave EXTRA_OUTPUT (uri with location where image should be saved), then in result you will get “small sized image is returned as a Bitmap object”.

    So just add uri to intent when requesting a picture and pass same uri to ACTION_SEND:

    case R.id.Picture:
        i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(MediaStore.EXTRA_OUTPUT, getUriForNewFile()); // you have to implement youself getUriForNewFile()
    
        startActivityForResult(i, cameraData);
    
        break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a WinForms app that takes a screenshot on a set
I am trying to create and iOS app that takes a users credentials and
I'm trying to create a small app that takes a base text template with
I am trying to create an app that allows you to go to a
I'm trying to create an app that multiple users would log into a server
I am trying to create an app that calculates the time difference and the
I am trying to create a simple app that displays a list of items
So I'm trying to create an iphone app that does simple temperature conversion and
I am trying to create an iPad app that reads a video on a
I'm trying to create an app for Android that simply sends a command to

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.