Created
January 4, 2013 07:29
-
-
Save shakalaca/4450669 to your computer and use it in GitHub Desktop.
點擊按鈕導引使用者進入 Facebook 專頁, 如果使用者有安裝 facebook client, 由它開啟, 否則開啟行動版網頁.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
連結到 https://graph.facebook.com/<你的專頁名稱> 找出 id, 那麼你的 url 就會是 fb://profile/<id> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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