需要帮助在手机的默认浏览器打开一个URL [英] Need help opening a url in the phone's default browser
问题描述
我试图让测试程序,按下一个按钮会打开一个网站。我已经做了听众和一切,我的问题就是这样,网址开放脚本,使一个错误,并告诉我:开放的我们解决不了。这里的剧本我用它来打开一个网页:
I'm trying to make test-program that opens a website by pushing a button. I have made a listener and everything, my problem is just that, the url-opening-script makes an error and tells me "Uri cannot be resolved". Here's the script I use to open up an webpage:
Intent browserIntent = new Intent("android.intent.action.VIEW",Uri.parse("http://www.google.com"));
startActivity(browserIntent);
我有进口android.app.Activity;
,进口android.content.Intent;
和进口android.content.ContentUris;
(也许是不需要的最后一个),所以我不能找出什么是错的...
I have the import android.app.Activity;
, import android.content.Intent;
and import android.content.ContentUris;
(maybe the last one isn't needed) so I can't find out what's wrong...
我希望有人知道我做错了,或者忘记导入...
I hope someone knows what I've done wrong, or forgot to import...
P.S。我用这个页面去我所在的地方:
P.S. I've used this pages to get to where I am:
<一个href=\"http://stackoverflow.com/questions/2201917/android-open-url-from-$c$c\">http://stackoverflow.com/questions/2201917/android-open-url-from-$c$c
<一href=\"http://stackoverflow.com/questions/3004515/android-sending-an-intent-to-browser-to-open-specific-url\">http://stackoverflow.com/questions/3004515/android-sending-an-intent-to-browser-to-open-specific-url
推荐答案
导入Uri类。如果您使用的是Eclipse可以按Ctrl-Shift-O组合添加需要进口,并删除未使用的。
Import the Uri class. If you are using Eclipse you can hit ctrl-shift-o to add needed imports, and remove unused ones.
这篇关于需要帮助在手机的默认浏览器打开一个URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!