WEB开发网
开发学院手机开发Android 开发 Android Intent 用法汇总 阅读

Android Intent 用法汇总

 2010-04-13 06:16:00 来源:WEB开发网   
核心提示:startActivity(it);//传送消息Uri uri = Uri.parse("smsto://0800000123");Intent it = new Intent(Intent.ACTION_SENDTO, uri);it.putExtra("sms_body",

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);

//传送 MMS

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);

传送 Email

Java代码

Uri uri = Uri.parse("mailto:xxx@abc.com");

Intent it = new Intent(Intent.ACTION_SENDTO, uri);

startActivity(it);

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");

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={"me@abc.com"};

String[] ccs={"you@abc.com"};

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 it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");

it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");

sendIntent.setType("audio/mp3");

startActivity(Intent.createChooser(it, "Choose Email Client"));

Uri uri = Uri.parse("mailto:xxx@abc.com");

Intent it = new Intent(Intent.ACTION_SENDTO, uri);

上一页  1 2 3 4 5  下一页

Tags:Android Intent 用法

编辑录入:coldstar [复制链接] [打 印]
赞助商链接