Android:单击按钮时转到 HTTP URL

发布于 2024-08-31 16:54:33 字数 149 浏览 6 评论 0原文

我想通过单击 Android 应用程序中的按钮来访问网页。比如说,我有一个名为“Google”的按钮,当用户单击该按钮时,我希望 google.com 在屏幕上打开。这是如何实现的?

另外,当用户使用完 Google 后,有没有办法可以重新获得对我的应用程序的控制权?

I want to go to a web page on the click of a button in my Android app. So say, I have a button called "Google", when the user clicks on that button I want google.com to open up on the screen. How is this achieved?

Also, is there a way I can gain control back to my app once the user is finished with Google?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ヤ经典坏疍 2024-09-07 16:54:33

在你的活动中做这样的事情。

public void openWebURL( String inURL ) {
    Intent browse = new Intent( Intent.ACTION_VIEW , Uri.parse( inURL ) );

    startActivity( browse );
}

默认情况下,退出浏览器应返回到您的活动。然而,在某些情况下可能不会。

In your activity do something like this.

public void openWebURL( String inURL ) {
    Intent browse = new Intent( Intent.ACTION_VIEW , Uri.parse( inURL ) );

    startActivity( browse );
}

By default, quitting the browser should return to your activity. However, there may be situations where it will not.

微凉 2024-09-07 16:54:33

此代码将带您进入网页

public void goToWebPage(String yourUrl) 
{
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(yourUrl));
    startActivity(intent);
}

This code will take you to the web page

public void goToWebPage(String yourUrl) 
{
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(yourUrl));
    startActivity(intent);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文