Sending image by email, Android?

I'm trying to make an application to capture an image and send it by email, I successfully made it by the following code

    String path = Images.Media.insertImage(getContentResolver(), bmp,"title", null);
    Uri screenshotUri = Uri.parse(path);
    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent
            .putExtra(android.content.Intent.EXTRA_EMAIL, emailAddresses);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
    emailIntent.setType("image/png");
    startActivity(Intent.createChooser(emailIntent, "Send email using"));

But the image is sent in a small size and very low resolution ?! Any suggestions for sending the image with it's actual size and resolution ?! Or is there any other way to get a jpeg image from the camera result instead of a bitmap ?!

Thanks in advance

Answers


bmp is a Bitmap I assume? Then you can save the image by use the compress http://developer.android.com/reference/android/graphics/Bitmap.html#compress%28android.graphics.Bitmap.CompressFormat,%20int,%20java.io.OutputStream%29 method from the bitmap class to write it to a file, and then create a Uri from the file.

When you insert an image, the Uri you receive from Media can be a reduced version.


Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, EMAIL_SUBJECT);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, EMAIL_TEXT);
File newFile = new File(Environment.getExternalStorageDirectory(), IMAGE_PATH);
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(newFile));
startActivity(emailIntent);

Need Your Help

Can't open Xcode project in Xcode 4.5 after opening it in Xcode 5

ios xcode storyboard xcode4.5 xcode5

I'm working with another iOS programmer together on a project. Other programmer installed Xcode 5 on his computer and opened the project. After he sent me the project, I can't open it in my older X...

Possibility of using 3rd-party app to open Uber app then going back to 3rd-party app on iOS

ios swift uber-api deeplink

I'm developing an iOS app that embeds UberRides feature. However, all of the example codes I can find online is about opening up Uber app after request button is pushed in my own app. I'm wondering...