在网上搜集了一些Intent和URI的应用实例,特作记录,以后会不断补充更新:
1.Install安装程序
Uri uri = Uri.fromParts(“package”, packageName, null); //packageName为包名,比如com.android123.apkInstaller
Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, uri);
startActivity(intent);
2.Uninstall卸载程序
Uri uri = Uri.fromParts("package", packageName, null); //packageName为包名,比如com.android123.apkInstaller
Intent itent = new Intent(Intent.ACTION_DELETE, uri);
startActivity(intent);
3.打开一个网页
Uri uri = Uri.parse(“http://hi.baidu.com/yimifeitian/home”);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
4.显示地图上位置
Uri uri = Uri.parse(“geo:52.76,-79.0342″);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
5.显示地图上路径
Uri uri = Uri.parse(“http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en”);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent); //where startLat, startLng, endLat, endLng are a long with 6 decimals like: 50.123456
6.打电话
//打开拨号界面
Uri uri = Uri.parse(“tel:10086″);
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent);
//直接拨打电话
Uri uri = Uri.parse(“tel:10086″);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
startActivity(intent);
7.播放音频文件
Uri uri = Uri.parse(“file:///sdcard/download/everything.mp3″);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setType(“audio/mp3″);
startActivity(intent);
8.发邮件
//打开发邮件界面
Uri uri= Uri.parse(“mailto:admin@3gstdy.com”);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(intent);
//直接将邮件发送出去
Intent intent = new Intent(Intent.ACTION_SEND);
String[] tos = { “admin@3gstdy.com” };
String[] ccs = { “webmaster@3gstdy.com” };
intent.putExtra(Intent.EXTRA_EMAIL, tos);
intent.putExtra(Intent.EXTRA_CC, ccs);
intent.putExtra(Intent.EXTRA_TEXT, “I come from http://blog.3gstdy.com”);
intent.putExtra(Intent.EXTRA_SUBJECT, “http://blog.3gstdy.com”);intent.setType(“message/rfc882″);
Intent.createChooser(intent, “Choose Email Client”);
//发送带附件的邮件
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);
intent.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/mysong.mp3″);
intent.setType(“audio/mp3″);
startActivity(Intent.createChooser(intent, “Choose Email Client”));
9.发短信
Uri uri= Uri.parse(“tel:10086″);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra(“sms_body”, “I come from http://blog.3gstdy.com”);
intent.setType(“vnd.Android-dir/mms-sms”);
startActivity(intent);
10.发彩信
Uri uri= Uri.parse(“content://media/external/images/media/23″);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(“sms_body”, “3g android http://blog.3gstdy.com”);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType(“image/png”);
startActivity(intent);
不断更新中。。。。。。。。。。