我已经为图片实现了幻灯片功能,现在需要将当前页面设置为电子邮件的正文并在phonegap中共享。我可以发送电子邮件但不能发送图像,我可以将第一个图像设置为当前页面并设置路径吗?请帮我为滑动图像提供正确的路径。
这是我的java意图代码
private void doSendIntent(String subject, String text) {
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);
this.cordova.startActivityForResult(this, sendIntent, 0);
File path = new File(Environment.getExternalStorageDirectory()+"file_path");
sendIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(new File(path.getAbsolutePath())));
}
在javascript中实现了图片滑动。
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide red-slide">
<img src="images/v2.jpg" >
<div class="wrapper">
<button class="button" id="Email" onclick="share()">Hello</button> </div>
</div>
<div class="swiper-slide blue-slide">
<img src="images/v.jpg" >
<div class="wrapper">
<button class="button" id="Email" onclick="share()">Hello</button>
</div>
</div>
<div class="pagination"></div>
</div>
<script>
var mySwiper = new Swiper('.swiper-container',{
pagination: '.pagination',
paginationClickable: true
})
</script>
答案 0 :(得分:0)
试试这个
sendIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()+filepath.jpg)));
答案 1 :(得分:0)
尝试设置类型
Bitmap icon = mBitmap;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
如果您正在尝试使用资源文件夹,请查看此Image preview in email Intent not showing when loaded from Assets Folder