1

I am using the Facebook Sdk 4.1.0 as dependency in my app. To do login, I follow this instructions: Can't get location and email using Facebook API

And login works fine if the Facebook apps is installed in the device but if the Facebook app is not installed (login goes throw a webview created by facebook) then my app crash if the user click on the button login inside the webview:

enter image description here

And if the user press de Log in button the app crash inmediatly:

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application at android.view.ViewRootImpl.setView(ViewRootImpl.java:559) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:269) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at android.app.Dialog.show(Dialog.java:289) at android.app.AlertDialog$Builder.show(AlertDialog.java:951) at com.android.webview.chromium.WebViewContentsClientAdapter.onSavePassword(WebViewContentsClientAdapter.java:752) at com.android.org.chromium.android_webview.AwContentsClientCallbackHelper$1.handleMessage(AwContentsClientCallbackHelper.java:157) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5271) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:851) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:667) at dalvik.system.NativeStart.main(Native Method)

Community
  • 1
  • 1
esteban
  • 543
  • 4
  • 18
  • Can you put your code of webview dialog class? You are using wrong context to show dialog thats the reason the null error is coming. – Surender Kumar Jun 22 '15 at 15:14
  • I don't have any webview. The webview is launched by Facebook because the facebook app is not installed in the device. – esteban Jun 22 '15 at 15:51

2 Answers2

1

I changed the Facebook Sdk to 4.0 instead of 4.1 and now is working. Unbelievable.

esteban
  • 543
  • 4
  • 18
0

there was an issue with you permissions you are passing you have to debug the code you can test it by changing your permissions request...

Puneet Kumar
  • 306
  • 1
  • 3
  • What permissions do you mean? At the facebook developer web or in the code? Maybe the `loginButton.setReadPermissions(permissionNeeds);` ? – esteban Jun 22 '15 at 20:47