在 Android 中打开 Facebook Messenger [英] Open Facebook Messenger in Android

查看:33
本文介绍了在 Android 中打开 Facebook Messenger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过代码打开facebook messenger.我如何获得脸书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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆