WEB开发网
开发学院手机开发Android 开发 Android Intent 用法集合 阅读

Android Intent 用法集合

 2010-04-15 17:46:00 来源:WEB开发网   
核心提示:Intent it = new Intent(Intent.ACTION_SEND);it.putExtra("sms_body", "some text");it.putExtra(Intent.EXTRA_STREAM, uri);it.setType("image

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

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("file:///sdcard/song.mp3");

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

it.setType("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);

//Market 相关

//寻找某个应用

Uri uri = Uri.parse("market://search?q=pname:pkg_name");

Tags:Android Intent 用法

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