Facebook SDK 3.0 Android login custom title bar disappears

随声附和 提交于 2019-12-12 03:45:01

问题


When I'm launching the login/register Facebook Activity using the openSession method the application title bar (we're using a custom one) disappears and another one appears. Is there a way to set the custom bar for the new Activity as well?

The way I'm calling the Facebook authorization:

        fb.openSession(this, new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            Logger.d(LOGTAG, "Session moved to state " + state.name());
            if (null == exception) {
                mFacebookSession = session;
                switch (state) {
                case CLOSED:
                case CLOSED_LOGIN_FAILED:
                    mLoginProgressDialog.dismiss();
                    Toast.makeText(FacebookLoginActivity.this, "Login failed. Verify login and password",
                            Toast.LENGTH_LONG).show();
                    break;
                case OPENED:
                case OPENED_TOKEN_UPDATED:
                    mFacebookSession.removeCallback(this);
                    FacebookServer.getInstance(getApplicationContext()).setSession(mFacebookSession);
                    FacebookServer.getInstance(getApplicationContext()).getUserFacebookId(
                            new FacebookLoginActivityUserIDCallback());
                    break;
                case OPENING:
                    break;
                default:
                    mLoginProgressDialog.dismiss();
                    break;
                }
            } else {
                exception.printStackTrace();
            }

        }
    });

We set up the custom title bar in the onCreate() method of the Activity that calls the above method:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.facebook_login_activity);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.app_title_bar);

The images below show what the problem is:


回答1:


Ultimately, I simply added these lines to LoginActivity.java in the Facebook package:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.app_title_bar);

It affected the layout of the activity FB is launching when performing actions and the look is now consistent.



来源:https://stackoverflow.com/questions/14347710/facebook-sdk-3-0-android-login-custom-title-bar-disappears

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!