0

我已经实现了图像的幻灯片功能,现在需要将当前页面设置为电子邮件的正文并在 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> 
4

2 回答 2

0

尝试这个

sendIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()+filepath.jpg)));
于 2013-09-17T11:19:00.257 回答
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"));

如果您正在尝试使用资产文件夹,请查看电子邮件中的此图像预览 Intent 从资产文件夹加载时不显示

于 2013-09-17T11:30:04.040 回答