如何以编程方式在android中发送视频到电子邮件

时间:2012-03-30 11:31:43

标签: android android-intent

我想将30秒的视频发送到我的Android应用程序的电子邮件。我已经发送了带有图片附件的电子邮件,但它不适用于video.plese帮助我做到这一点,提前谢谢。

send.setOnClickListener(new OnClickListener() 
{
    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    final Intent emailIntent = new Intent(
    android.content.Intent.ACTION_SEND);
    emailIntent.setType("video/3gp");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
    new String[] { address.getText().toString() });
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
    subject.getText());
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
    emailtext.getText());
    String dataPath = "/sdcard/video0007.3GP"; 
   emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(dataPath));
    startActivity(Intent.createChooser(emailIntent,"Send mail..."));
  }
});

1 个答案:

答案 0 :(得分:3)

使用此代码从SD卡中挑选视频,然后发送带有视频的电子邮件.....

Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("video/3gp");
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Video");
       sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/dcim/Camera/filename.3gp"));
        sendIntent.putExtra(Intent.EXTRA_TEXT, "Enjoy the Video");
        startActivity(Intent.createChooser(sendIntent, "Email:"));  

使用此代码发送电子邮件,然后浏览您的视频...如果出现任何错误或问题...请告诉我......

已编辑的答案

private void message() 
    {

        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = "Here is the share content body";
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, "Send via"));

    }