没有指定URL的Android推出的浏览器 [英] Android launch browser without specifying a URL
问题描述
如何将一去发起一项活动的浏览器,而无需指定的URL。我想打开浏览器,以便用户可以继续浏览不改变他们的网页?
How would one go about launching the browser from an activity without specifying a url. I would like to open the browser so the user can continue browsing without changing the page they were on?
解决方法: 下面的答案是正确的工作,但更具体的为未来的读者,这里是工作code:
SOLUTION: Answer below was correct and worked, but to be more specific for future readers, here is the working code:
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setAction("com.android.browser");
ComponentName comp = new ComponentName("com.android.browser", "com.android.browser.BrowserActivity");
i.setComponent(comp);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
谢谢!
推荐答案
使用<一个href="http://developer.android.com/reference/android/content/Intent.html#setClassName%28java.lang.String,%20java.lang.String%29"相对=nofollow>意向#setComponent()设置浏览器的包和类名。然后启动该活动。
Use Intent#setComponent() to set the Browser's package and class name. Then start the activity.
这篇关于没有指定URL的Android推出的浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!