我开发一个应用程序,在那里我产生使用的EditText字段中的图像(textArea.setDrawingCacheEnabled(真); textArea.buildDrawingCache(真);),并将其保存在SD卡上。 而在同一时间,我想的是图像使用ACTION_SEND意图的其他应用程序之间共享。 在这里,我所面临的问题是,我能够生成的EditText图像,但相同的图像不获取连接到目的(在这个例子中份额的意图 ),请告诉我,我要去哪里错了..
提前致谢..
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
File picDir = new File(Environment.getExternalStorageDirectory()
+ "/myPic");
if (!picDir.exists()) {
picDir.mkdir();
}
textArea.setDrawingCacheEnabled(true);
textArea.buildDrawingCache(true);
Bitmap bitmap = textArea.getDrawingCache();
Date date = new Date();
String fileName = "img" + date.getTime() + ".png";
File picFile = new File(picDir + "/" + fileName);
try {
picFile.createNewFile();
FileOutputStream picOut = new FileOutputStream(picFile);
boolean saved = bitmap.compress(CompressFormat.PNG, 100,
picOut);
if (saved) {
Toast.makeText(
getApplicationContext(),
"Image saved to your device Pictures "
+ "directory!", Toast.LENGTH_SHORT).show();
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory() +"/" +picFile));
startActivity(Intent.createChooser(share, "Send picture using:"));
} else {
//Error
}
picOut.close();
} catch (Exception e) {
e.printStackTrace();
}
textArea.destroyDrawingCache();
} else {
//Error
}