共计 2147 个字符,预计需要花费 6 分钟才能阅读完成。
浏览器关上连贯
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(intent);
启动拨号程序
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:186xxxxxxxx"));
startActivity(intent);
发送短信
Uri smsUri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, smsUri);
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);
启动通讯录
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/1"));
startActivity(intent);
启动地图程序(Google Maps 等)
Uri mapUri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, mapUri);
startActivity(intent);
启动邮件程序
Uri uri =Uri.parse("mailto:harlansong@qq.com");
Intent intent = newIntent(Intent.ACTION_SENDTO, uri);
intent.putExtra(Intent.EXTRA_SUBJECT, "Hello world");
intent.putExtra(Intent.EXTRA_TEXT, "Ganbarimasu");
startActivity(intent);
阐明:启动邮件程序并将收件人设为 harlansong@qq.com,邮件主题设为 Hello world,内容设为 Ganbarimasu。
启动邮件程序并增加多个收件人
Intent intent=new Intent(Intent.ACTION_SEND);
String[] tos={"me@example.com"};
String[]ccs={"you@example.com"};
intent.putExtra(Intent.EXTRA_EMAIL, tos);
intent.putExtra(Intent.EXTRA_CC, ccs);
intent.putExtra(Intent.EXTRA_TEXT, "The email body text");
intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
intent.setType("message/rfc822");
startActivity(Intent.createChooser(intent,"Choose Email Client"));
启动邮件程序并增加附件
Intent intent = newIntent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
intent.putExtra(Intent.EXTRA_STREAM,"file:///sdcard/mysong.mp3);
sendIntent.setType("audio/mp3");
startActivity(Intent.createChooser(intent,"Choose Email Client"));
播放音乐文件
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri =Uri.parse("file:///sdcard/song.mp3");
intent.setDataAndType(uri,"audio/mp3");
startActivity(intent);
卸载程序
Uri uri =Uri.fromParts("package", strPackageName, null);
Intent intent = newIntent(Intent.ACTION_DELETE, uri);
startActivity(intent);
阐明:卸载包名为 strPackageName 的程序。
安装程序
Uri installUri = Uri.fromParts("package",strPackageName, null);
returnIt = newIntent(Intent.ACTION_PACKAGE_ADDED, installUri);
阐明:安装包名为 strPackageName 的程序。
启动利用市场
Uri uri=Uri.parse("market://search?q=pname:org.breezesoft.techolite");
Intent intent=new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);
正文完