【发布时间】:2012-10-12 07:09:14
【问题描述】:
当我单击我的 android 应用程序中的按钮时,我想导航到 facebook 粉丝页面。 我是安卓新手。谁能帮我做这件事。
【问题讨论】:
-
你有没有试过任何答案?
标签: android android-intent android-button
当我单击我的 android 应用程序中的按钮时,我想导航到 facebook 粉丝页面。 我是安卓新手。谁能帮我做这件事。
【问题讨论】:
标签: android android-intent android-button
你为什么不这样尝试。
String url = "http://www.facebook.com/yourfanpagename";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
将上面的代码放在你的按钮点击中。
【讨论】:
只需使用意图。 这是一个例子,
在按钮的点击事件中:
// 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());
}
希望这会有所帮助!
【讨论】:
您可以通过两种方式做到这一点:
使用intent打开浏览器,如下:
String url = "http://www.facebook.com/your_page";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
在布局中使用 webview 并在应用程序中打开链接。这样更可取。
你可以找到链接here来实现它。
【讨论】: