简体   繁体   English

在Android中,如果已经在设备中安装了Facebook,为什么Facebook注册不起作用?

[英]In Android, why is Facebook signup not working if Facebook installed in the device already?

I have tried to use Facebook in my application, this works fine on device that doesn't have Facebook app installed. 我试图在我的应用程序中使用Facebook,但在未安装Facebook应用程序的设备上运行正常。 But this fails to give the session while there is Facebook already installed on the device. 但是,如果设备上已经安装了Facebook,则无法进行会话。

public void facebookSignIn(CallbackContext callContext){
    try {
        isFacebookLogin = true;
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                mConnectionProgressDialog.show();               }
        });
        this.callbackContext = callContext;
        Session.openActiveSession(this, true, new Session.StatusCallback() {
            // callback when session changes state
            @Override
            public void call(Session session, SessionState state, Exception exception) {
                Log.d("facebook","session open");
                if (session.isOpened()) {
                    // make request to the /me API
                    Request.newMeRequest(session, new Request.GraphUserCallback() {
                        // callback after Graph API response with user object
                        @Override
                        public void onCompleted(GraphUser user, Response response) {
                            if (user != null) {
                                String userID = user.getId();
                                callbackContext.success(userID);
                                Toast.makeText(MDLIVEMain.this, user.getName() + " is connected.", Toast.LENGTH_LONG).show();
                            } else {
                                // TODO: handle exception
                                callbackContext.error(MDLiveLocalizationSystem.localizedStringForKey("nat_authen_failure"));
                            }
                            getActivity().runOnUiThread(new Runnable() {
                                public void run() {
                                    mConnectionProgressDialog.dismiss();
                                }
                            });
                        }

                    }).executeAsync();
                }
            }
        });
    }catch (Exception e){
        e.printStackTrace();
        callbackContext.error(MDLiveLocalizationSystem.localizedStringForKey("nat_authen_failure"));
        GATrackingExceptions.trackExceptions(e.getLocalizedMessage(), MDLIVEMain.this);
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                mConnectionProgressDialog.dismiss();
            }
        });
    }
}

Here is onactivityResult code 这是onactivityResult代码

  @Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    try {
        CordovaPlugin callback = this.activityResultCallbacks;
        if (callback != null) {
            callback.onActivityResult(requestCode, responseCode, intent);
        }
        Log.d("isFacebookLogin",isFacebookLogin+"");
        if(isFacebookLogin){
            try {
                isFacebookLogin = false;
                Session.getActiveSession().onActivityResult(this, requestCode, responseCode, intent);
            }catch (Exception e){
                e.printStackTrace();
            }
        }else {
            if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
                mConnectionResult = null;
                mPlusClient.connect();
            }

            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    mConnectionProgressDialog.dismiss();
                }
            });

            if (requestCode == PASSCODE_RESULT_PAGE) {
                if (responseCode == RESULT_OK) {
                    activityVisible = true;
                    this.callbackContext.success(intent.getExtras().getString("passcode_pin"));
                } else {
                    this.callbackContext.success(intent.getExtras().getString("passcode_pin"));
                    isFromPasscodePage = true;
                }
            }
        }
    }catch (Exception e){
        e.printStackTrace();
    }
}

I have answered for this type of (Hash for fb) issue here : 我已经在这里为这种类型的(fb哈希)问题回答了:

Facebook Login and Post To Wall works for first time only Facebook登录和张贴到墙仅首次使用

Note: Fb gives issues bcz of not valid Hash, for that you have to generate a valid hash. 注意:Fb给出了无效哈希的问题bcz,因为您必须生成有效哈希。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当Facebook应用程序已经安装时,Facebook在android中的集成无效 - Facebook integration in android is not working when Facebook app is already installed 设备上已安装fb时,Android Facebook SSO不起作用 - Android Facebook SSO does not work when fb is already installed on device 当Facebook应用程序已安装在设备上时,Android Facebook帖子不起作用 - Android Facebook post does not work when the Facebook app is already installed on the device Android Facebook登录无法与安装的本机Facebook一起使用 - android facebook login is not working with native facebook installed Android facebook 登录不适用于已安装的 Facebook 应用程序 - Android facebook login not working with installed Facebook app Android Facebook oAuth-尚未安装代理的应用程序 - Android Facebook oAuth - The proxied app is not already installed 如果Facebook本机应用程序安装在设备中,Facebook登录不起作用? - Facebook login not working if Facebook native application installed in device? 如果设备中安装了 facebook 应用程序,则在我的 android 应用程序中登录 facebook 会出现问题 - Issue with facebook login in my android application if facebook application is installed in device Facebook集成可以在模拟器中运行,但不能在Android设备中运行吗? - Facebook integration working in emulator but not working in android device? 使用 Facebook 的 Android 应用程序登录不适用于已安装的 Facebook 应用程序 - Android Application Login with Facebook is not working with Facebook App installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM