在Android中打开Facebook Messenger [英] Open Facebook Messenger in Android
本文介绍了在Android中打开Facebook Messenger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过代码打开Facebook Messenger.我如何获得Facebook ID? 我的应用程序上有facebook SDK,我为每个用户保存了facebookId,但与我需要的不一样
I want to open facebook messenger by code. How I can get the facebook ID?? I have the facebook SDK on my app and I saved for every user the facebookId but is not the same as I need
这是我的方法:
// Make sure the Facebook Messenger for Android client is installed
boolean isFBInstalled = isAppInstalled("com.facebook.orca");
if (!isFBInstalled) {
Toast.makeText(this,"Facebook messenger isn't installed. Please download the app first.", Toast.LENGTH_SHORT)
.show();
}
else {
// Create the Intent
Uri uri = Uri.parse("fb-messenger://user/");
uri = ContentUris.withAppendedId(uri,Long.valueOf(facebookIDhere);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
try {
startActivity(intent);
}
catch(Exception e) {
Toast.makeText(this,"Oups!Can't open Facebook messenger right now. Please try again later.", Toast.LENGTH_SHORT)
.show();
}
}
return;
推荐答案
转到某人的Facebook个人资料.右键单击个人资料图片,然后复制链接地址.将其粘贴到文本编辑器上,您将在URL的末尾看到"referrer_profile_id"参数.这是该用户的Facebook ID.
Go to someone's facebook profile. Right click on the profile picture and copy the link address. Paste it on a text editor and you will see the "referrer_profile_id" parameter at the end of the URL. It is the facebook ID of that user.
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://messaging/" + FbUserID));
startActivity(i);
这篇关于在Android中打开Facebook Messenger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文