android手机打开facebook允许权限窗口的问题

标签 android facebook

在我的应用程序中,我正在尝试连接 facebook。登录后如果有权限会询问是否允许,也可以贴墙。

同一个应用程序在模拟器上可以正常工作,但在手机登录窗口和允许权限窗口不会出现。 为什么会这样?

在我的登录代码下方,

  public class LoginListener implements DialogListener {

        @Override
        public void onComplete(Bundle values) {
            if (testAuthenticatedApi())
                System.out.println("Login successfully...");
            if (testAuthenticatedErrors()) {
                System.out.println("Login successfully...");
            }
        }
}


 public boolean testAuthenticatedApi() {
        if (!facebook.isSessionValid()) 
            return false;
        try {
            Log.d("Tests", "Testing request for 'me'");
            String response = facebook.request("me");
            JSONObject obj = Util.parseJson(response);
            if (obj.getString("name") == null || 
                    obj.getString("name").equals("")) {
                return false;
            }

            Log.d("Tests", "Testing graph API wall post");
            Bundle parameters = new Bundle();
            parameters.putString("message", "hello world");
            parameters.putString("description", "test test test");
            response = facebook.request("me/feed", parameters, 
                    "POST");
            Log.d("Tests", "got response: " + response);
            if (response == null || response.equals("") || 
                    response.equals("false")) {
                return false;
            }

            Log.d("Tests", "Testing graph API delete");
            response = response.replaceAll("\\{\"id\":\"", "");
            response = response.replaceAll("\"\\}", "");
            response = facebook.request(response, new Bundle(), 
                    "DELETE");
            if (!response.equals("true")) return false;

            Log.d("Tests", "Testing old API wall post");
            parameters = new Bundle();
            parameters.putString("method", "stream.publish");
            parameters.putString("attachment", 
                "{\"name\":\"Name=Title\"," +
                "\"href\":\"http://www.google.fr/\",\"" +
                "caption\":\"Caption\",\"description\":\"Description" +
                "\",\"media\":[{\"type\":\"image\",\"src\":" +
                "\"http://www.kratiroff.com/logo-facebook.jpg\"," +
                "\"href\":\"http://developers.facebook.com/\"}]," +
                "\"properties\":{\"another link\":{\"text\":\"" +
                "Facebook homepage\",\"href\":\"http://www.facebook." +
                "com\"}}}");;
            response = facebook.request(parameters);
            Log.d("Tests", "got response: " + response);
            if (response == null || response.equals("") || 
                    response.equals("false")) {
                return false;
            }

            Log.d("Tests", "Testing wall post delete");
            response = response.replaceAll("\"", "");
            response = facebook.request(
                    response, new Bundle(), "DELETE");
            if (!response.equals("true")) return false;

            Log.d("Tests", "All Authenticated Tests Passed");
            return true;
        } catch (Throwable e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean testAuthenticatedErrors() {
        if (!facebook.isSessionValid()) return false;

        Log.d("Tests", "Testing that request for 'me/invalid' is rejected");
        try {
            Util.parseJson(facebook.request("me/invalid"));
            return false;
        } catch (Throwable e) {
            Log.d("Tests", "*" + e.getMessage() + "*");
            if (!e.getMessage().equals("Unknown path components: /invalid")) {
                return false;
            }
        }

        Log.d("Tests", "Testing that old API call with invalid method fails");
        Bundle params = new Bundle();
        params.putString("method", "something_invalid");
        try {
            Util.parseJson(facebook.request(params));
            return false;
        } catch (Throwable e) {
            Log.d("Tests", "*" + e.getMessage() + "*");
            if (!e.getMessage().equals("Unknown method") ) {
                return false;
            }
        }

        Log.d("Tests", "All Authenticated Error Tests Passed");
        return true;
    }

最佳答案

问题可能出在登录的 SSO(单点登录)功能上。

以下链接可能会有帮助。

facebook login dialog disappears soon after loading

http://ukgupta.blogspot.com/2011/07/facebook-implementation-into-android.html

关于android手机打开facebook允许权限窗口的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7346704/

相关文章:

php - 有没有办法用 PHP 获取 Facebook 页面的名称?

android - 将相册中的图片发布到我的墙上

Android Lint 看不到未使用的 png 可绘制对象

android - ViewModel + 数据绑定(bind)中的最佳实践和模式。 ViewModel中的ObservableField可以吗?

java - 使用广播接收器在通话结束后获取最后通话记录的详细信息

android - 如何在 iPhone 和 Android 的 Titanium 中实现 Google Analytic?

安卓 repo SSL CERTIFICATE_VERIFY_FAILED

objective-c - 检查 iOS 上的 Facebook 权限

javascript - Facebook Like 和 Google +1 按钮在部分回发时消失

javascript - facebook 分享对话框重定向而不是弹出?