要通过彩信共享图像,代码正在运行。我所做的是,将可绘制图像转换为位图并保存在 SD 卡中。并检索以通过意图发送,这是一张图像,我很惊讶将数组中的所有图像发送到 SD 卡。在下面的代码中,我将图像从可绘制的数组中放置,并将所有 4 个图像转换为位图,如何将这 4 个图像发送到 sdcard?
private void doSendIntent(String subject, String text) {
try {
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
sendIntent.setType("image/png");
ArrayList<Integer> myImageList = new ArrayList<Integer>();
myImageList.add(R.drawable.gicon);
myImageList.add(R.drawable.ic_launcher);
myImageList.add(R.drawable.loadin);
myImageList.add(R.drawable.splash);
Bitmap bbicon;
bbicon = BitmapFactory.decodeResource(this.cordova.getActivity().getResources(),
R.drawable.gicon);
bbicon = BitmapFactory.decodeResource(this.cordova.getActivity().getResources(),
R.drawable.ic_launcher);
bbicon = BitmapFactory.decodeResource(this.cordova.getActivity().getResources(),
R.drawable.loadin);
bbicon = BitmapFactory.decodeResource(this.cordova.getActivity().getResources(),
R.drawable.splash);
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
OutputStream outStream = null;
File f = new File(extStorageDirectory + "/Download/",
"gicon.png");
try {
outStream = new FileOutputStream(f);
bbicon.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
System.out.println("ssssssssssssssssss");
} catch (Exception e) {
}
}
//RETRIEVING IMAGES FROM SDCARD
File fl = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/Download/", "gicon.png");
Uri uri = Uri.fromFile(fl);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
this.cordova.startActivityForResult(this, sendIntent, 0);
}
catch(Exception e)
{
System.out.println(" no error here");
e.printStackTrace();
}