gpt4 book ai didi

android - 隐式 Intent 查看 URL

转载 作者:太空宇宙 更新时间:2023-11-03 12:08:14 25 4
gpt4 key购买 nike

我是 Android 新手,我想创建一个 Intent 来查看谷歌网站。我的字符串声明如下:

static private final String URL = "http://www.google.com";

和我的 Intent :

Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setData(Uri.parse("geo:+URL"));
startActivity(browserIntent);

此代码在 Eclipse 中没有显示错误,但我认为它可能是错误的。

最佳答案

在尝试连接 2 个字符串时,您没有正确构建 Uri,请使用:

String s = "I'm a string variable";

String concatenated = s + " and I'm another String variable";

现在concatenated的内容是

I'm a string variable and I'm another String variable

如果你这样做:

String concatenated = "s + and I'm another String variable";

concatenated的内容是

s + and I'm another String variable

其次,您为什么要使用地理 Uri?这是为了查看位置。要查看网站,只需使用 URL(不要忘记“http://”部分):

String URL = "http://www.google.com";
browserIntent.setData(Uri.parse(URL));

关于android - 隐式 Intent 查看 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21636269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com