Android调用邮件客户端

简介: main.xml如下: mainActivity如下: package c.c; import android.

main.xml如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="发送邮件" />

</RelativeLayout>


mainActivity如下:

package c.c;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
/**
 * Demo描述:
 * 调用设备上的邮件客户端发送邮件
 * 在此会列出该设备上的所有邮件客户端,供用户选择
 */
public class MainActivity extends Activity {
    private Button mButton;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		init();
	}
    private void init(){
    	mButton=(Button) findViewById(R.id.button);
    	mButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				startSendEmail();
			}
		});
    }
    private void startSendEmail() {
		String address="test@sina.com";
		String subject="邮件的标题";
		String body="邮件的内容";
		String content = "mailto:"+address+"?subject="+subject+"&body="+body;
		Intent returnIt = new Intent(Intent.ACTION_SENDTO);
		returnIt.setData(Uri.parse(content));
		startActivity(Intent.createChooser(returnIt, "Send email tips"));
	}

}


 

相关文章
|
5月前
|
Linux Android开发 iOS开发
基于.Net开发的ChatGPT客户端,兼容Windows、IOS、安卓、MacOS、Linux
基于.Net开发的ChatGPT客户端,兼容Windows、IOS、安卓、MacOS、Linux
88 0
|
4月前
|
XML JSON Java
Android App开发即时通信中通过SocketIO在客户端与服务端间传输文本和图片的讲解及实战(超详细 附源码)
Android App开发即时通信中通过SocketIO在客户端与服务端间传输文本和图片的讲解及实战(超详细 附源码)
69 0
|
7月前
|
缓存 安全 Android开发
[Android 毕业设计/课程设计] 小而美的阅读客户端 App
[Android 毕业设计/课程设计] 小而美的阅读客户端 App
|
9月前
|
Android开发 iOS开发 Windows
无影产品动态|iOS & Android客户端6.0.0版本发布,提升触控灵敏度,操作体验更丝滑
无影ios & Android客户端6.0.0版本发布!移动端触控体验更舒适,用户操作更便捷,一起来看看!
678 0
无影产品动态|iOS & Android客户端6.0.0版本发布,提升触控灵敏度,操作体验更丝滑
|
移动开发 Java Android开发
uni-app&H5&Android混合开发三 || uni-app调用Android原生方法的三种方式
uni-app&H5&Android混合开发三 || uni-app调用Android原生方法的三种方式
1350 0
uni-app&H5&Android混合开发三 || uni-app调用Android原生方法的三种方式
|
JavaScript 前端开发 Android开发
JS(Javascript)调用Android原生方法三步走
JS(Javascript)调用Android原生方法三步走
464 0
|
Web App开发 弹性计算 Android开发
阿里云无影云桌面客户端下载Win/Mac/iOS/安卓/Web端均支持
阿里云无影客户端下载系统Win/Mac/iOS/安卓/Web端均支持
3559 0
阿里云无影云桌面客户端下载Win/Mac/iOS/安卓/Web端均支持
|
Android开发
《58同城Android客户端Walle框架演进与实践之路》电子版地址
58同城Android客户端Walle框架演进与实践之路
56 0
《58同城Android客户端Walle框架演进与实践之路》电子版地址