Skip to content

Instantly share code, notes, and snippets.

@shakalaca
Created January 4, 2013 07:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shakalaca/4450669 to your computer and use it in GitHub Desktop.
Save shakalaca/4450669 to your computer and use it in GitHub Desktop.
點擊按鈕導引使用者進入 Facebook 專頁, 如果使用者有安裝 facebook client, 由它開啟, 否則開啟行動版網頁.
連結到 https://graph.facebook.com/<你的專頁名稱> 找出 id, 那麼你的 url 就會是 fb://profile/<id>
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/<id>"));
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
if (activities.size() != 0) {
startActivity(intent);
} else {
intent.setData(Uri.parse("https://www.facebook.com/<你的專頁名稱>"));
startActivity(intent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment