我是 Android新手,我想创建一个Intent来查看谷歌网站.我的String声明如下: static private final String URL = "http://www.google.com"; 和我的意图: Intent browserIntent = new Intent(Intent.ACTION_VIEW);browserIntent
static private final String URL = "http://www.google.com";
和我的意图:
Intent browserIntent = new Intent(Intent.ACTION_VIEW); browserIntent.setData(Uri.parse("geo:+URL")); startActivity(browserIntent);
此代码在Eclipse中没有显示错误,但我认为这可能是错误的.
在尝试连接2个String时,你没有正确构建你的Uri,请使用:String s = "I'm a string variable"; String concatenated = s + " and I'm another String variable";
现在连接的内容是
I’m a string variable and I’m another String variable
如果你这样做:
String concatenated = "s + and I'm another String variable";
连接的内容是
s + and I’m another String variable
其次,你为什么要使用地理Uri?这是用于查看位置.要查看网站,只需使用URL(不要忘记“http://”部分):
String URL = "http://www.google.com"; browserIntent.setData(Uri.parse(URL));