我正在实现一个应用程序。
基于我的应用程序,我创建了一个名为"RepeatingAlarm.java“的类
我的RepeatingAlarm类扩展了广播接收器。
我每隔一小时就会给上面的班级打电话。
我的要求是,当调用这个类时
我想从sdcard上获取一个文件,然后通过电子邮件发送这个文件。
如果有人知道解决方案,请帮助我。
提前感谢
发布于 2012-07-04 17:41:42
将这些代码添加到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-04 18:11:36
这是一个完整的示例,它向其他人发送一封后台电子邮件(使用gmail帐户),当然还有附件。Send email with attachment using GMAIL account.
如果您不需要ZipUtility类,请将其移除并根据需要使用它
https://stackoverflow.com/questions/11326121
复制相似问题