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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:17:13+00:00 2026-06-14T17:17:13+00:00

I have been fighting with a problem all morning and thought I would ask

  • 0

I have been fighting with a problem all morning and thought I would ask here now.

I use the following code to attach 9 patch images to an email:

sendIntent.setType("image/png");

ArrayList<Uri> uris = new ArrayList<Uri>();

uris.add(Uri.parse("android.resource://com.android9patch.viewer/raw/" + mBaseFilename + String.format("%05d", mAppBackgroundCurrentFile)) );

sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(Intent.createChooser(sendIntent, "Email:"));

The problem is that when I get the email, the image is not the original 9 patch, but the version without the scale and padding markers.

I should get this result:
Expected result attachment

But I get this instead:
Result received

I suspect that the app processes the raw file before sending it?

Additional information:

I am now attempting to save the file to the SDCARD before attaching them to the email. Well, for some reason, even copying removes the scale and padding markers… I don’t get it.

Here is my copy function I took from raw copy function.

private boolean copyToSDCard( int resourceID, String finalName )
{
    String extStorageDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString();
    OutputStream out = null;

    try
    {
        InputStream in = getResources().openRawResource( resourceID );
        out = new FileOutputStream(extStorageDirectory + "/" + finalName + ".9.png");
        copyFile(in, out);
        in.close();
        in = null;
        out.flush();
        out.close();
        out = null;
    }
    catch (Exception e)
    {
        Log.e("copyToSDCard", e.toString());
        e.printStackTrace();
    }

    return false;
}

private void copyFile(InputStream in, OutputStream out) throws IOException {
    byte[] buffer = new byte[1024];
    int read;
    while((read = in.read(buffer)) != -1){
      out.write(buffer, 0, read);
    }
}
  • 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-14T17:17:14+00:00Added an answer on June 14, 2026 at 5:17 pm

    I ended up copying the asset to the sdcard and attaching this new file to the email using the following functions:

    ...
    if( copyAssetToSDCard( filename, basepath + filename ) )
    {
        uris.add( Uri.parse( "file://" + basepath + filename ) );
    }
    ...
    
    
    private boolean copyAssetToSDCard( String SrcFilename, String DstFilename )
    {
        OutputStream out = null;
    
        try
        {
            AssetManager assetManager = getResources().getAssets();
            InputStream in = assetManager.open(SrcFilename);
            out = new FileOutputStream(DstFilename);
            copyFile(in, out);
            in.close();
            in = null;
            out.flush();
            out.close();
            out = null;
    
            return true;
        }
        catch (Exception e)
        {
            Log.e("copyToSDCard", e.toString());
            e.printStackTrace();
        }
    
        return false;
    }
    
    private void copyFile(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[1024];
        int read;
        while((read = in.read(buffer)) != -1){
          out.write(buffer, 0, read);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been fighting with this code for a few hours now.... Sample Node
I've been fighting with this problem all day and am just about at my
I've been fighting this all day. Inside my styles.xml file I have color information
I have been fighting this problem with the help of a RegEx cheat sheet,
I've been fighting this crazy problem for hours and have gotten nowhere. I have
I have been fighting for a few hours with different type of code to
I have been fighting this issue for days now and about to beat my
I have been fighting with this for a couple of days now. I can't
For the last 2 hours I have been fighting with this problem and trying
I have been fighting with this upload problem for a couple of days and

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.