package com.example.sendemail;
import android.app.Activity;
import android.app.SearchManager;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.os.Build;
import android.provider.MediaStore;
import android.provider.MediaStore.Audio.Media;
import android.provider.MediaStore.Images;
public class MainActivity extends Activity implements View.OnClickListener{
private Button mSendBtn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mSendBtn=(Button)findViewById(R.id.send_btn);
mSendBtn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.send_btn:
startSendEmailIntent();
break;
}
}
private void startSendEmailIntent(){
//邮件
Intent data=new Intent(Intent.ACTION_SENDTO);
data.setData(Uri.parse("mailto:
[email protected]"));
data.putExtra(Intent.EXTRA_SUBJECT, "这是标题");
data.putExtra(Intent.EXTRA_TEXT, "这是内容");
startActivity(data);
//百度从google搜索内容
//
Intent intent = new Intent();
//
intent.setAction(Intent.ACTION_WEB_SEARCH);
//
intent.putExtra(SearchManager.QUERY,"searchString");
//
startActivity(intent);
//.浏览网页
//
Uri uri = Uri.parse("http://www.google.com");
//
Intent it = new Intent(Intent.ACTION_VIEW,uri);
//
startActivity(it);
//.显示地图
//
Uri uri = Uri.parse("geo:38.899533,-77.036476");
//
Intent it = new Intent(Intent.ACTION_VIEW,uri);
//
startActivity(it);
//路径规划
//
Uri uri = Uri.parse("http://maps.google.com/maps?f=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
//
Intent it = new Intent(Intent.ACTION_VIEW,uri);
//
startActivity(it);
//拨打电话
//
Uri uri = Uri.parse("tel:xxxxxx");
//
Intent it = new Intent(Intent.ACTION_DIAL, uri);
//
startActivity(it);
//调用发短信的程序
//
Intent it = new Intent(Intent.ACTION_VIEW);
//
it.putExtra("sms_body", "The SMS text");
//
it.setType("vnd.android-dir/mms-sms");
//
startActivity(it);
//发送短信 没有测试
//
Uri uri = Uri.parse("smsto:0800000123");
//
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
//
it.putExtra("sms_body", "The SMS text");
//
startActivity(it);
//
String body="this is sms demo";
//
Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", number, null));
//
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);
//
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true);
//
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true);
//
startActivity(mmsintent);
//发送彩信 没有测
//
Uri uri = Uri.parse("content://media/external/images/media/23");
//
Intent it = new Intent(Intent.ACTION_SEND);
//
it.putExtra("sms_body", "some text");
//
it.putExtra(Intent.EXTRA_STREAM, uri);
//
it.setType("image/png");
//
startActivity(it);
//
StringBuilder sb = new StringBuilder();
//
sb.append("file://");
//
sb.append(fd.getAbsoluteFile());
//
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto", number, null));
//
// Below extra datas are all optional.
//
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject);
//
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);
//
intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString());
//
intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode);
//
intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent);
//
startActivity(intent);
//9.发送Email
//
Uri uri = Uri.parse("mailto:
[email protected]");
//
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
//
startActivity(it);
//
Intent data=new Intent(Intent.ACTION_SENDTO);
//
data.setData(Uri.parse("mailto:
[email protected]"));
//
data.putExtra(Intent.EXTRA_SUBJECT, "这是标题");
//
data.putExtra(Intent.EXTRA_TEXT, "这是内容");
//
startActivity(data);
//发送Email 短信 qq好友
//
Intent it = new Intent(Intent.ACTION_SEND);
//
it.putExtra(Intent.EXTRA_EMAIL, "
[email protected]");
//
it.putExtra(Intent.EXTRA_TEXT, "The email body text");
//
it.setType("text/plain");
//
startActivity(Intent.createChooser(it, "Choose Email Client"));
//
Intent it=new Intent(Intent.ACTION_SEND);
//
String[] tos={"
[email protected]"};
//
String[] ccs={"
[email protected]"};
//
it.putExtra(Intent.EXTRA_EMAIL, tos);
//
it.putExtra(Intent.EXTRA_CC, ccs);
//
it.putExtra(Intent.EXTRA_TEXT, "The email body text");
//
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
//
it.setType("message/rfc822");
//
startActivity(Intent.createChooser(it, "Choose Email Client"));
//
Intent intent = new Intent(Intent.ACTION_SEND); //启动分享发送的属性
//
intent.setType("text/plain"); //分享发送的数据类型
//
intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); //分享的主题
//
intent.putExtra(Intent.EXTRA_TEXT, "extratext"); //分享的内容
//
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//这个也许是分享列表的背景吧
//
MainActivity.this.startActivity(Intent.createChooser(intent, "分享"));//目标应用选择对话框的标题
//
Intent it = new Intent(Intent.ACTION_SEND);
//
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
//
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
//
it.setType("audio/mp3");
//
startActivity(Intent.createChooser(it, "Choose Email Client"));
//播放多媒体
//
Intent it = new Intent(Intent.ACTION_VIEW);
//
Uri uri = Uri.parse("file:///sdcard/song.mp3");
//
it.setDataAndType(uri, "audio/mp3");
//
startActivity(it);
//需要研究
//
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
//
Intent it = new Intent(Intent.ACTION_VIEW, uri);
//
startActivity(it);
//uninstall apk
//
Uri uri = Uri.fromParts("package", strPackageName, null);
//
Intent it = new Intent(Intent.ACTION_DELETE, uri);
//
startActivity(it);
//install apk
//
Uri installUri = Uri.fromParts("package", "xxx", null);
//
return It = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
// 打开照相机 可以用的
//
Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON, null);
// this.sendBroadcast(i);
// 打开照相机 可以用的
//
long dateTaken = System.currentTimeMillis();
// String name = createName(dateTaken) + ".jpg";
// //fileName = folder + name;
// ContentValues values = new ContentValues();
// values.put(Images.Media.TITLE,"");
// values.put("_data","");
// values.put(Images.Media.PICASA_ID,"");
// values.put(Images.Media.DISPLAY_NAME,"");
// values.put(Images.Media.DESCRIPTION,"");
// values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME,"");
// Uri photoUri = getContentResolver().insert(
// MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
//
// Intent inttPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// inttPhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
// startActivityForResult(inttPhoto, 10);
//
// }
//
private String createName(long dateTaken) {
//
// TODO Auto-generated method stub
//
return null;
//
}
//.从gallery选取图片
//
Intent i = new Intent();
// i.setType("image/*");
// i.setAction(Intent.ACTION_GET_CONTENT);
// startActivityForResult(i, 11);
// 打开录音机
//
Intent mi = new Intent(Media.RECORD_SOUND_ACTION);
//
startActivity(mi);
//显示应用详细列表
//Uri uri = Uri.parse("market://details?id=app_id");
//
Uri uri = Uri.parse("market://details?id=<packagename>");
//
Intent it = new Intent(Intent.ACTION_VIEW, uri);
//
startActivity(it);
//where app_id is the application ID, find the ID
//by clicking on your application on Market home
//page, and notice the ID from the address bar
//
刚才找app id未果,结果发现用package name也可以
//
Uri uri = Uri.parse("market://details?id=<packagename>");
//
这个简单多了
//寻找应用
//
Uri uri = Uri.parse("market://search?q=pname:pkg_name");
//
Intent it = new Intent(Intent.ACTION_VIEW, uri);
//
startActivity(it);
//where pkg_name is the full package path for an application
case R.id.iv_sms://短信
Intent intent = new Intent();
//系统默认的action,用来打开默认的短信界面
intent.setAction(Intent.ACTION_SENDTO);
//需要发短息的号码
intent.setData(Uri.parse("smsto:"+tv_mobile.getText().toString()));
startActivity(intent);
break;
case R.id.iv_phone://电话
Uri uri = Uri.parse("tel:"+tv_mobile.getText().toString());
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
break;
case R.id.iv_email://邮件
//邮件
Intent data=new Intent(Intent.ACTION_SENDTO);
//到时候该成动态的
data.setData(Uri.parse("mailto:
[email protected]"));
data.putExtra(Intent.EXTRA_SUBJECT, "这是标题");
data.putExtra(Intent.EXTRA_TEXT, "这是内容");
startActivity(data);
break;
}
}