0

我正在实施一个应用程序。

基于我的应用程序,我创建了名为“RepeatingAlarm.java”的类

我的 RepeatingAlarm 类扩展了广播接收器。

我每隔一小时就给上面的班级打电话。

我的要求是,当这个类被调用时

我想从 sdcard 获取文件并通过电子邮件发送此文件。

如果有人知道解决方案,请帮助我。

提前致谢

4

2 回答 2

3

在您的 BroadcastReceiver 中的 onReceive 方法中添加这些内容。

   File file= new File(Environment.getExternalStorageDirectory()
                    + "/filefolder/"+"filename");
Uri u1  =   null;
u1  =   Uri.fromFile(file);

Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sending a file");
 sendIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] 
        {"me@gmail.com"}); 
sendIntent.putExtra(Intent.EXTRA_STREAM, u1);
sendIntent.setType("text/html");
context.startActivity(Intent.createChooser(sendIntent , "Send mail..."));
于 2012-07-04T09:41:42.213 回答
1

这是一个完整的示例,它向其他人发送背景电子邮件(使用 gmail 帐户),当然还有附件。使用 GMAIL 帐户发送带附件的电子邮件。

如果您不需要 ZipUtility 类,请将其删除并根据需要使用它

于 2012-07-04T10:11:36.290 回答