WEB开发网
开发学院手机开发Android 开发 Android Intent的几种用法全面总结 阅读

Android Intent的几种用法全面总结

 2010-06-22 02:20:00 来源:WEB开发网   
核心提示:it.putExtra("sms_body", "some text");it.putExtra(Intent.EXTRA_STREAM, uri);it.setType("image/png");startActivity(it);复制代码发送EmailUr

it.putExtra("sms_body", "some text");

it.putExtra(Intent.EXTRA_STREAM, uri);

it.setType("image/png");

startActivity(it);

复制代码

发送Email

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

复制代码

添加附件 来源:(http://blog.sina.com.cn/s/blog_692ead9c0100jl82.html) - Android Intent的几种用法全面总结_dreakdog_新浪博客

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

复制代码

播放多媒体

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,

Tags:Android Intent 用法

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