9贴片png原始资源附加到电子邮件是不是原始文件
问题描述:
我一直在一个问题整个上午奋斗,并认为我现在要问这里。9贴片png原始资源附加到电子邮件是不是原始文件
我用下面的代码9个图像附加到电子邮件:
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:"));
的问题是,当我收到的电子邮件,图像是不是原来的9补丁,但版本没有规模和填充标记。
我应该得到这样的结果:
,但我得到这个代替:
我怀疑是应用处理原始文件发送之前?
信息:
我现在试图将文件复制到SD卡保存附加到电子邮件之前。那么,出于某种原因,即使复制也会删除比例和填充标记...我不明白。
这是我从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);
}
}
答
我结束了资产复制到SD卡,并使用以下功能这个新的文件附加到电子邮件:
...
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);
}
}