【问题标题】:android how to navigate a web site on button click [closed]android如何在按钮单击时导航网站[关闭]
【发布时间】:2012-10-12 07:09:14
【问题描述】:

当我单击我的 android 应用程序中的按钮时,我想导航到 facebook 粉丝页面。 我是安卓新手。谁能帮我做这件事。

【问题讨论】:

标签: android android-intent android-button


【解决方案1】:

你为什么不这样尝试。

String url = "http://www.facebook.com/yourfanpagename";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

将上面的代码放在你的按钮点击中。

【讨论】:

    【解决方案2】:

    只需使用意图。 这是一个例子,

    在按钮的点击事件中:

    // Open Website
        Intent intent;
    
        try {
            intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/yourPage"));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        } catch (Exception e) {
            Log.e("Exception Caught", e.toString());
        }
    

    希望这会有所帮助!

    【讨论】:

      【解决方案3】:

      您可以通过两种方式做到这一点:

      1. 使用intent打开浏览器,如下:

        String url = "http://www.facebook.com/your_page";
        Intent i = new Intent(Intent.ACTION_VIEW);
        
        i.setData(Uri.parse(url));
        startActivity(i);
        
      2. 在布局中使用 webview 并在应用程序中打开链接。这样更可取。

      你可以找到链接here来实现它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-18
        • 1970-01-01
        • 1970-01-01
        • 2020-03-25
        相关资源
        最近更新 更多