EX06_05.java
上传用户:vip_99
上传日期:2021-03-27
资源大小:61159k
文件大小:2k
- package irdc.EX06_05;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.widget.TextView;
- public class EX06_05 extends Activity
- {
- /*声明一个TextView,String数组与两个文本字符串变量*/
- private TextView mTextView1;
- public String[] strEmailReciver;
- public String strEmailSubject;
- public String strEmailBody;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- /*通过findViewById构造器创建TextView对象*/
- mTextView1 = (TextView) findViewById(R.id.myTextView1);
- mTextView1.setText("等待接收短信...");
-
- try
- {
- /*取得短信传来的bundle*/
- Bundle bunde = this.getIntent().getExtras();
- if (bunde!= null)
- {
- /*将bunde内的字符串取出*/
- String sb = bunde.getString("STR_INPUT");
- /*自定义一Intent来运行寄送E-mail的工作*/
- Intent mEmailIntent =
- new Intent(android.content.Intent.ACTION_SEND);
- /*设置邮件格式为"plain/text"*/
- mEmailIntent.setType("plain/text");
-
- /*
- * 取得EditText01,02,03,04的值作为
- * 收件人地址,附件,主题,正文
- */
- strEmailReciver =new String[]{"jay.mingchieh@gmail.com"};
- strEmailSubject = "你有一封短信!!";
- strEmailBody = sb.toString();
-
- /*将取得的字符串放入mEmailIntent中*/
- mEmailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
- strEmailReciver);
- mEmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
- strEmailSubject);
- mEmailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
- strEmailBody);
- startActivity(Intent.createChooser(mEmailIntent,
- getResources().getString(R.string.str_message)));
- }
- else
- {
- finish();
- }
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }