Facebook android sdk v4 login cancel

I need to implement facebook login in my application. Here is my class:

manifest:

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> <activity android:name="com.facebook.FacebookActivity" android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:label="@string/app_name" /> <provider android:authorities="com.facebook.app.FacebookContentProvider" android:name="com.facebook.FacebookContentProvider" android:exported="true" /> 

And my class:

 public abstract class FaceBookActivityImpl extends BaseActivity { private CallbackManager callbackManager; private ShareDialog shareDialog; @Override protected void initView() { FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { } @Override public void onCancel() { } @Override public void onError(FacebookException e) { } }); FacebookSdk.addLoggingBehavior(LoggingBehavior.REQUESTS); } public CallbackManager getCalbackManager(){ return callbackManager; } public ShareDialog getShareDialog(){ if(shareDialog==null){ shareDialog = new ShareDialog(this); // this part is optional shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { DebugLog.d("share success " + result.getPostId()); } @Override public void onCancel() { } @Override public void onError(FacebookException e) { } }); } return shareDialog; } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); callbackManager.onActivityResult(requestCode, resultCode, data); } 

}

When the user enters the login, I need to check publish_actions for such an action:

 LoginManager.getInstance().registerCallback(((MainActivity) getContext()).getCalbackManager(), new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { DebugLog.d("login fb success "+loginResult.getRecentlyGrantedPermissions()); likeTopic(); } @Override public void onCancel() { DebugLog.d("login fb cancel"); } @Override public void onError(FacebookException e) { DebugLog.d("login fb error "+e.getMessage()); } }); LoginManager.getInstance().logInWithPublishPermissions(((MainActivity) getContext()), Arrays.asList("publish_actions")); 

But it always cancels:

 DebugLog.d("login fb cancel"); 

What am I missing, please help me, I have been doing research for a long time. Thank you very much.

Edit: when this happened, logcat (without filter) shows:

 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.login.LoginClient$Request" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67) at java.lang.ClassLoader.loadClass(ClassLoader.java:497) at java.lang.ClassLoader.loadClass(ClassLoader.java:457) 

+5
source share
3 answers

I think this problem occurs if the device has its own application for Facebook. Try to run the code on a device on which the Facebook application is not installed.

Also , try removing the application from the Facebook developer page and adding it again.

See related questions here.

Cannot log in to Facebook if the Facebook application is installed

Android Class not found: class not found ... by path: DexPathList: class reference failed: **

Update is important

You need to add the Application Identifier at the end of FacebookContentProvider , for example FacebookContentProvider1234 , if 1234 is your application identifier. For example

 <provider android:authorities="com.facebook.app.FacebookContentProvider1234" android:name="com.facebook.FacebookContentProvider" android:exported="true" /> 
0
source

I want to avoid using the Facebook application to use the Facebook login feature to use only the dialog box:

 LoginManager.getInstance().setLoginBehavior( LoginBehavior.SUPPRESS_SSO ); 

or, if the LoginButton element is used to login:

 loginButton.setLoginBehavior( LoginBehavior.SUPPRESS_SSO ); 
0
source

I have exactly the same problem using facebook sdk 4.6.0 when I disable the installed facebook application. It took some time to understand that everything is working fine if the facebook application is not installed or the facebook application is installed.

In this regard, it is a very special case when the facebbook application is installed and disabled, and also because I also provide google login. I am not investigating more time on this issue.

Happy day

0
source

All Articles