I am trying to migrate the login code of an old application from SDK 3.0 to SDK 4.0. I logged in with LoginManager since I have custom login buttons.
The problem is that I am not getting a response from the Facebook API. There were no successes, mistakes, no exceptions. The code is as follows:
//global refs //callbacks private CallbackManager mCallbackManager; private FacebookCallback<LoginResult> mFacebookCallback; private List<String> mPermissions = Arrays.asList("email"); private LoginManager mLoginMgr; private Activity mActivity; //........ //code is inside method FacebookSdk.sdkInitialize(getApplicationContext()); //perhaps a bit excessive FacebookSdk.addLoggingBehavior(LoggingBehavior.GRAPH_API_DEBUG_INFO); FacebookSdk.addLoggingBehavior(LoggingBehavior.DEVELOPER_ERRORS); FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS); FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_RAW_RESPONSES); FacebookSdk.setApplicationId(mActivity.getString(R.string.sample_fb_id)); //init callbacks mFacebookCallback = new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.v("LoginActivity login", loginResult.toString()); GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject object, GraphResponse response) { // Application code Log.v("LoginActivity", response.toString()); try { String email = object.getString("email"); Log.v("LoginActivity", "obtained email: ", email); } catch (JSONException e) { e.printStackTrace(); } } }); request.executeAsync(); } @Override public void onCancel() { Log.e("LoginActivity", "facebook login canceled"); } @Override public void onError(FacebookException e) { Log.e("LoginActivity", "facebook login failed error"); } }; mCallbackManager = CallbackManager.Factory.create(); mLoginMgr = LoginManager.getInstance(); mLoginMgr.registerCallback(mCallbackManager, mFacebookCallback); mLoginMgr.logInWithReadPermissions(mActivity, mPermissions);
Using Debugger , I can see this line: mLoginMgr.logInWithReadPermissions(mActivity, mPermissions); executes, but none of the callbacks fires. I also have no errors in the console, and the device screen goes black and nothing happens.
I do not think this is important, but the code is executed in a wrapper class (outside of Activity ). I tried inside the Activity , but that didn't matter.
Any suggestions? Very much appreciated.
Edit:
This is declared inside AndroidManifest.xml :
<activity android:name="com.facebook.FacebookActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" />
nightfixed
source share