• 大小: 0.03M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-02-01
  • 标签: Android  Intent  

资源简介

Android Intent开发实例


核心代码:


package com.amaker.ch06.app;

import com.amaker.ch06.app.R;

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;
import android.widget.EditText;

/**
 * @author 郭宏志
 * 发送Email
 */
public class MainActivity extends Activity {
	// 声明视图组件
	private EditText toEditText,subjectEditText,contentEditText;
	private Button sendBtn;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        // 实例化视图组件
        toEditText = (EditText)findViewById(R.id.toEditText01);
        subjectEditText = (EditText)findViewById(R.id.subjectEditText01);
        contentEditText = (EditText)findViewById(R.id.contentEditText01);
        
        sendBtn = (Button)findViewById(R.id.sendButton01);
        // 为按钮添加单击监听器
        sendBtn.setOnClickListener(listener);
    }
    
    
    // 发送按钮单击监听器
    private OnClickListener listener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			// 获得输入信息
			String to = toEditText.getText().toString();
			String subject = subjectEditText.getText().toString();
			String content = contentEditText.getText().toString();
			// 创建Intent
			Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
			// 设置内容类型
			emailIntent.setType("plain/text");
			// 设置额外信息
			emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{to});
			emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
			emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content);
			
			startActivity(Intent.createChooser(emailIntent, "发送邮件..."));
			
		}
	};
}


资源截图

代码片段和文件信息

/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package com.amaker.ch06.app;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
    }
    public static final class id {
        public static final int TextView01=0x7f050000;
        public static final int TextView02=0x7f050002;
        public static final int TextView03=0x7f050004;
        public static final int contentEditText01=0x7f050005;
        public static final int sendButton01=0x7f050006;
        public static final int subjectEditText01=0x7f050003;
        public static f

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\
     文件         280  2010-01-14 20:47  Chapter06_Intent_Email\.classpath
     文件         858  2010-02-22 10:04  Chapter06_Intent_Email\.project
     文件         765  2010-02-22 10:05  Chapter06_Intent_Email\AndroidManifest.xml
     目录           0  2014-11-24 16:43  Chapter06_Intent_Email\assets\
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\bin\
     文件        8936  2010-03-26 21:42  Chapter06_Intent_Email\bin\Chapter06_Intent_Email.apk
     文件        4192  2010-03-26 21:42  Chapter06_Intent_Email\bin\classes.dex
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\bin\com\
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\bin\com\amaker\
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\bin\com\amaker\ch06\
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\bin\com\amaker\ch06\app\
     文件        1926  2010-03-26 21:42  Chapter06_Intent_Email\bin\com\amaker\ch06\app\MainActivity$1.class
     文件        1531  2010-03-26 21:42  Chapter06_Intent_Email\bin\com\amaker\ch06\app\MainActivity.class
     文件         343  2010-03-26 21:42  Chapter06_Intent_Email\bin\com\amaker\ch06\app\R$attr.class
     文件         403  2010-03-26 21:42  Chapter06_Intent_Email\bin\com\amaker\ch06\app\R$drawable.class
     文件         613  2010-03-26 21:42  Chapter06_Intent_Email\bin\com\amaker\ch06\app\R$id.class
     文件         397  2010-03-26 21:42  Chapter06_Intent_Email\bin\com\amaker\ch06\app\R$layout.class
     文件         430  2010-03-26 21:42  Chapter06_Intent_Email\bin\com\amaker\ch06\app\R$string.class
     文件         538  2010-03-26 21:42  Chapter06_Intent_Email\bin\com\amaker\ch06\app\R.class
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\bin\com\amaker\ch07\
     目录           0  2014-11-24 16:43  Chapter06_Intent_Email\bin\com\amaker\ch07\app\
     文件        5244  2010-03-26 21:42  Chapter06_Intent_Email\bin\resources.ap_
     文件         449  2010-01-14 20:47  Chapter06_Intent_Email\default.properties
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\gen\
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\gen\com\
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\gen\com\amaker\
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\gen\com\amaker\ch06\
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\gen\com\amaker\ch06\app\
     文件        1094  2010-03-26 21:42  Chapter06_Intent_Email\gen\com\amaker\ch06\app\R.java
     目录           0  2014-05-03 19:10  Chapter06_Intent_Email\gen\com\amaker\ch07\
............此处省略14个文件信息

评论

共有 条评论