启动浏览器
代码与范例:
1
2
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(intent); |
说明:启动浏览器并前往http://www.google.com 。
启动拨号程序
代码与范例:
1
2
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:138"));
startActivity(intent); |
说明:启动拨号程序并输入号码138。
通话
代码与范例:
1
2
3
|
Uri uri=Uri.parse("tel:138");
Intent intent=new Intent(Intent.ACTION_CALL,uri);
startActivity(intent); |
说明:拨打号码138。需要为程序申请权限<uses-permission android:name=”android.permission.CALL_PHONE”/>。
发送短信
代码与范例:
1
2
3
4
|
Uri smsUri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, smsUri);
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent); |
说明:启动短信程序。
启动通讯录
代码与范例: