1、打开地图
public void showMap() {
//根据地名打开地图应用显示,字符串要记得编码!!
String encodedName = Uri.encode("贵州省人民医院");
Uri locationUri = Uri.parse("geo:0,0?q="+encodedName);
//根据经纬度打开地图显示,?z=11表示缩放级别,范围为1-23
// Uri locationUri = Uri.parse("geo:26.5789070770,106.7170012064?z=11");
Intent intent = new Intent(Intent.ACTION_VIEW);
Intent chooser = Intent.createChooser(intent, "请选择地图软件");
intent.setData(locationUri);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}
}
2、打开浏览器
如果你想让用户在电子邮件或浏览器或其他应用中,点击你的某个网址时打开的是APP而不是网页时,你可以给APP的对应界面加入如下intent过滤器:
<activity ...>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" android:host="你的服务器域名" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
启动浏览器
public void openWebPage() {
//最好写上http协议
Uri webpage = Uri.parse("https://www.baidu.com");
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}