Facebook Android應用程序不支持此操作的隱式意圖機制,因爲1.9.11版本。 Facebook現在使用相同的iPhone方案機制fb://
或facebook://
來處理提及的所有操作here。
在這裏你可以看到他們支持fb和facebook方案。
<activity android:name="com.facebook.katana.IntentUriHandler">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="facebook" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="fb" />
</intent-filter>
</activity>
根據您的要求,此方法將處理這兩種情況。首先它會檢查facebook應用程序是否安裝,否則它將在瀏覽器中打開Facebook配置文件頁面。
爲了與用戶配置文件的所有你需要做的打開Facebook的應用程序是:
Intent facebookIntent = getFBIntent(this, "2347633432");
startActivity(facebookIntent);
** 編輯 **
這是你如何調用以上方法在你的活動中。而已!
public class AboutActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ImageButton f = (ImageButton)findViewById(R.id.f_logo);
f.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
// Get the intent
Intent intent = getFBIntent(AboutActivity.this, "sarmad.waleed.7");
// Start the activity
if (intent != null)
startActivity(intent);
}
});
}
/**
* Get the facebook intent for the given facebook
* profile id. If the facebook app is installed, then
* it will open the facebook app. Otherwise, it will
* open the facebook profile page in browser.
*
* @return - the facebook intent
*/
private Intent getFBIntent(Context context, String facebookId) {
try {
// Check if FB app is even installed
context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
String facebookScheme = "fb://profile/" + facebookId;
return new Intent(Intent.ACTION_VIEW, Uri.parse(facebookScheme));
}
catch(Exception e) {
// Cache and Open a url in browser
String facebookProfileUri = "https://www.facebook.com/" + facebookId;
return new Intent(Intent.ACTION_VIEW, Uri.parse(facebookProfileUri));
}
return null;
}
}
答案可以在這裏找到http://stackoverflow.com/questions/10788247/opening-facebook-app-on-specified-profile-page – 2014-11-08 17:44:32
http://stackoverflow.com/questions/4191492/launch -face-app-from-other-app – 2014-11-08 17:44:45