机器人:为什么Facebook的注册,如果安装在设备的Facebook已经无法正常工作? [英] android : why Facebook signup not working if Facebook installed in the device already?

查看:211
本文介绍了机器人:为什么Facebook的注册,如果安装在设备的Facebook已经无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

0试图利用Facebook在我的应用程序,这工作正常的设备没有安装Facebook应用程序。但是,这不能给会话,同时在该设备上已安装的Facebook。任何一个可以帮助我在此

 公共无效facebookSignIn(CallbackContext CallContext中){
    尝试 {
        isFacebookLogin = TRUE;
        getActivity()。runOnUiThread(新的Runnable(){
            公共无效的run(){
                mConnectionProgressDialog.show(); }
        });
        this.callbackContext = CallContext中;
        Session.openActiveSession(这一点,真,新Session.StatusCallback(){
            //回调时,会话状态变化
            @覆盖
            公共无效呼叫(会话的会话,SessionState会状态,例外的例外){
                Log.d(脸谱,会议开);
                如果(session.isOpened()){
                    //使请求/ ME API
                    Request.newMeRequest(会话,新Request.GraphUserCallback(){
                        //后与用户对象图形API响应回调
                        @覆盖
                        公共无效onCompleted(GraphUser用户,响应响应){
                            如果(用户!= NULL){
                                字符串userid = user.getId();
                                callbackContext.success(用户ID);
                                Toast.makeText(MDLIVEMain.this,user.getName()+连接,Toast.LENGTH_LONG).show();
                            } 其他 {
                                // TODO:处理异常
                                callbackContext.error(MDLiveLocalizationSystem.localizedStringForKey(nat_authen_failure));
                            }
                            getActivity()。runOnUiThread(新的Runnable(){
                                公共无效的run(){
                                    mConnectionProgressDialog.dismiss();
                                }
                            });
                        }

                    })executeAsync()。
                }
            }
        });
    }赶上(例外五){
        e.printStackTrace();
        callbackContext.error(MDLiveLocalizationSystem.localizedStringForKey(nat_authen_failure));
        GATrackingExceptions.trackExceptions(e.getLocalizedMessage(),MDLIVEMain.this);
        getActivity()。runOnUiThread(新的Runnable(){
            公共无效的run(){
                mConnectionProgressDialog.dismiss();
            }
        });
    }
}
 

下面是onactivityResult code

  @覆盖
保护无效onActivityResult(INT申请code,INT响应code,意图意图){
    尝试 {
        CordovaPlugin回调= this.activityResultCallbacks;
        如果(回调!= NULL){
            callback.onActivityResult(要求code,响应code,意图);
        }
        Log.d(isFacebookLogin,isFacebookLogin +);
        如果(isFacebookLogin){
            尝试 {
                isFacebookLogin = FALSE;
                Session.getActiveSession()onActivityResult(这一点,要求code,响应code,意图)。
            }赶上(例外五){
                e.printStackTrace();
            }
        }其他 {
            如果(要求code == REQUEST_ code_RESOLVE_ERR和放大器;&安培;响应code == RESULT_OK){
                mConnectionResult = NULL;
                mPlusClient.connect();
            }

            getActivity()。runOnUiThread(新的Runnable(){
                公共无效的run(){
                    mConnectionProgressDialog.dismiss();
                }
            });

            如果(要求code == PASS code_RESULT_PAGE){
                如果(响应code == RESULT_OK){
                    activityVisible = TRUE;
                    this.callbackContext.success(intent.getExtras()的getString(通code_pin));
                } 其他 {
                    this.callbackContext.success(intent.getExtras()的getString(通code_pin));
                    isFromPass codePAGE = TRUE;
                }
            }
        }
    }赶上(例外五){
        e.printStackTrace();
    }
}
 

解决方案

我已经回答了这个类型的这里(哈希FB)问题:

<一个href="http://stackoverflow.com/questions/25356984/facebook-login-and-post-to-wall-works-for-first-time-only/25357104#25357104">Facebook登录后,为华尔街的作品第一次只

注:FB给出了问题的BCZ无效的哈希,为你生成一个有效的哈希值

O have tried to use Facebook in my application, this works fine on device that doesn't have Facebook app installed. But this fails to give the session while there is Facebook already installed on the device. Can any one help me on this

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

  @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 :

Facebook Login and Post To Wall works for first time only

Note: Fb gives issues bcz of not valid Hash, for that you have to generate a valid hash.

这篇关于机器人:为什么Facebook的注册,如果安装在设备的Facebook已经无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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