编写android代码使用隐式Intent启动浏览器
时间: 2023-06-05 14:04:22 浏览: 77
可以使用以下代码启动浏览器:
```
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
startActivity(intent);
```
这将打开默认浏览器并加载给定的 URL。注意,需要添加网络权限到你的 AndroidManifest.xml 文件中。
相关问题
android代码使用隐式Intent启动浏览器
可以使用以下代码启动浏览器:
```
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.parse("http://www.baidu.com");
intent.setData(uri);
startActivity(intent);
```
这将使用隐式Intent启动浏览器并跳转到百度网站。
帮我写使用隐式Intent启动浏览器、拨号、短信和相机的界面的代码
好的,以下是使用隐式Intent启动浏览器、拨号、短信和相机的代码:
启动浏览器:
```java
Uri uri = Uri.parse("https://www.baidu.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
```
启动拨号界面:
```java
Uri uri = Uri.parse("tel:10086");
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent);
```
启动发短信界面:
```java
Uri uri = Uri.parse("smsto:10086");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", "Hello World!");
startActivity(intent);
```
启动相机界面:
```java
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
```
需要注意的是,启动相机界面需要在onActivityResult()方法中获取拍摄的照片。