I embed the login via facebook and get the user email id using the SDK 4.1.0, as shown in the facebook documentation , but the problem is that every time after onActivityResult, when registerCallback is called, then onCancel is called instead of onSuccess.
package com.dexterous.hellologin;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
public class MainActivity2 extends ActionBarActivity {
CallbackManager callbackManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_main_activity2);
LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions("email");
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.e("TAG", "success");
}
@Override
public void onCancel() {
Log.e("TAG", "onCancel");
}
@Override
public void onError(FacebookException exception) {
Log.e("TAG", "error");
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
Log.e("TAG", "onActivityResult");
}
}
every time i get output
onActivityResult
Oncancel
I also get that facebook login screen containing cancel and login buttons.
after uninstalling facebook app from mobile error changed to Invalid app id
and this is stacktrace
06-04 10: 55: 16.631 19864-19864/com.dexterous.hellologin I/WebViewFactory: com.google.android.webview 42.0.2311.138 ( 2311138) 06-04 10: 55: 16.706 19864-19864/com.dexterous.hellologin I/LibraryLoader: : 4 ( 8772-8776) 06-04 10: 55: 16.706 19864-19864/com.dexterous.hellologin I/LibraryLoader: ", " "06-04 10: 55: 16.717 19864-19864/com.dexterous.hellologin W/art: IRT, 06-04 10: 55: 16.816 19864-19864/com.dexterous.hellologin V/WebViewChromiumFactoryProvider: Looper (main, tid 1) {28a6fbd9} 06-04 10: 55: 16.816 19864-19864/com.dexterous.hellologin I/LibraryLoader: " ", " " 06-04 10: 55: 16.819 19864-19864/com.dexterous.hellologin I/chromium: [INFO: library_loader_hooks.cc(112)] : level = 0, verbosity = 0 06-04 10: 55: 16.834 19864-19864/com.dexterous.hellologin I/BrowserStartupController: , singleProcess = true 06-04 10: 55: 16.838 19864-19864/com.dexterous.hellologin W/art: IRT, 06-04 10: 55: 16.841 19864-19864/com.dexterous.hellologin E/SysUtils: ApplicationContext null ApplicationStatus 06-04 10: 55: 16.869 19864-19864/com.dexterous.hellologin W/chromium: [: resource_bundle.cc(286)] locale_file_path.empty() 06-04 10: 55: 16.870 19864-19864/com.dexterous.hellologin I/chromium: [INFO: aw_browser_main_parts.cc(63)] apk succesful, fd = 63 off = 46992 len = 3337 06-04 10: 55: 16.871 19864-19864/com.dexterous.hellologin I/chromium: [INFO: aw_browser_main_parts.cc(76)] webviewchromium.pak , fd: 64 off: 7953032 len: 1161174 06-04 10: 55: 17.024 19864-19953/com.dexterous.hellologin W/chromium: [WARNING: data_reduction_proxy_config.cc(150)] SPDY proxy OFF 06-04 10: 55: 17.047 19864-19864/com.dexterous.hellologin W/art: IRT, 06-04 10: 55: 17.060 19864-19864/com.dexterous.hellologin W/AwContents: onDetachedFromWindow , . 06-04 10: 55: 24.893 19864-19864/com.dexterous.hellologin W/BindingManager: definVisibility() - pid: 19864 06-04 10: 55: 26.140 19864-20020/com.dexterous.hellologin E/Adreno-ES20:: ! ! 06-04 10: 55: 26.140 19864-20020/com.dexterous.hellologin E/Adreno-ES20:: Framebuffer. GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT! 06-04 10: 55: 26.198 19864-19912/com.dexterous.hellologin E/Adreno-ES20:: ! ! 06-04 10: 55: 26.198 19864-19912/com.dexterous.hellologin E/Adreno-ES20:: Framebuffer. GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT! 06-04 10: 58: 32.287 19864-19864/com.dexterous.hellologin E/TAG: onCancel 06-04 10: 58: 32.287 19864-19864/com.dexterous.hellologin E/TAG: onActivityResult 06-04 10: 59: 25.498 19864-19864/com.dexterous.hellologin I/art: GC 16056 (1325 ) AllocSpace, 0 (0B) LOS, 39% , 9 /16 , 856us 79.028
Manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.dexterous.hellologin.MainActivity2"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main_activity2" >
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="1437829111203883" />
</application>
</manifest>