android—Intent发送文本email

来源:互联网 发布:vesa图形编程系统 pdf 编辑:程序博客网 时间:2024/03/29 03:50

代码如下:

import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class MyIntentCaseDemo extends Activity {private Button mybut = null ;// 按钮组件@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);super.setContentView(R.layout.main);// 默认布局管理器this.mybut = (Button) super.findViewById(R.id.mybut) ;// 取得组件this.mybut.setOnClickListener(new OnClickListenerImpl());// 定义单击事件}private class OnClickListenerImpl implements OnClickListener { @Overridepublic void onClick(View view) {Intent emailIntent = new Intent(Intent.ACTION_SEND) ;// 实例化IntentemailIntent.setType("plain/text") ;// 设置类型String address[] = new String[]{"sdu@163.com"} ;// 收件人的地址String subject = "山东大学软件学院(SDU)" ;// 邮件主题String content = "山东大学软件学院(SDU)www.sdu.edu.cn" ;// 邮件内容emailIntent.putExtra(Intent.EXTRA_EMAIL, address) ;// 设置收件人emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject) ;// 设置主题emailIntent.putExtra(Intent.EXTRA_TEXT, content) ;// 设置内容MyIntentCaseDemo.this.startActivity(emailIntent);// 执行Intent}}}

所需权限:

<uses-permission android:name="android.permission.CALL_PHONE"/>

2 0
原创粉丝点击