Well, since you don't follow the guidelines of this forum, I don't
have much faith how much you follow FB's guidelines.

On Apr 16, 1:41 pm, Kamal Kambe <[email protected]> wrote:
> Hi,
>
> I'm trying to integrate facebook in my android application. I followed the
> guidelines provided in facebook developers page 
> -http://developers.facebook.com/docs/mobile/android/build/
>
> I was getting an exception while executing the following code:
>
> if (!facebook.isSessionValid()) {
> System.out.println("Facebook:: session invalid");
> facebook.authorize((GameActivity) ctx, new String[] {
> "read_friendlists", "user_likes", "email", "friends_likes",
> "user_interests", "friends_interests" },
> new DialogListener() {
>
> @Override
> public void onCancel() {
> // Function to handle cancel event
> System.out.println("Facebook:: event cancelled");
>
> }
>
> @Override
> public void onComplete(Bundle values) {
> // Function to handle complete event
> // Edit Preferences and update facebook acess_token
> System.out
> .println("Facebook:: setting access token and expire time in preferences");
> User user = User.getUser();
> if (user != null) {
> accessToken = facebook.getAccessToken();
> accessExpires = facebook.getAccessExpires();
> user.setAccessToken(accessToken);
> user.setAccessExpires(accessExpires);
> user.updatePrefs();
> mPrefs.flush();
> getFacebookFriends();
> getUserInfo();
>
> }
>
> @Override
> public void onError(DialogError error) {
> // Function to handle error
> System.out.println("Facebook:: Error - "
> + error.getLocalizedMessage());
>
> }
>
> @Override
> public void onFacebookError(FacebookError fberror) {
> // Function to handle Facebook errors
> System.out.println("Facebook:: fbError - code: "
> + fberror.getErrorCode() + "  message: "
> + fberror.getLocalizedMessage());
>
> }
> });
>
> Exception is:
>
> Can't create handler inside thread that has not called Looper.prepare()
> ...
> ...
> ...
>
> I went through net for this and added Looper.prepare(), Looper.loop() on
> either side of the above code like this
>
> Looper.prepare();
> FACEBOOK_AUTHORIZATION_CODE;
> Looper.loop();
>
> Sometimes it gives the following exception but sometimes it runs fine but
> the application freezes (I tried quit() method but it leads to some other
> error)
>
> Exception that comes sometimes is:
>
> I/ExceptionHandler( 2504): java.lang.NullPointerException
> I/ExceptionHandler( 2504): at
> android.webkit.WebView.onWindowFocusChanged(WebView.java:4177)
> I/ExceptionHandler( 2504): at
> android.view.View.dispatchWindowFocusChanged(View.java:3788)
> I/ExceptionHandler( 2504): at
> android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:658)
> I/ExceptionHandler( 2504): at
> android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662)
> I/ExceptionHandler( 2504): at
> android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662)
> I/ExceptionHandler( 2504): at
> android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662)
> I/ExceptionHandler( 2504): at
> android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:662)
> I/ExceptionHandler( 2504): at
> android.view.ViewRoot.handleMessage(ViewRoot.java:1921)
> I/ExceptionHandler( 2504): at
> android.os.Handler.dispatchMessage(Handler.java:99)
> I/ExceptionHandler( 2504): at android.os.Looper.loop(Looper.java:123)
> I/ExceptionHandler( 2504): at
> com.kiwi.monstercastle.facebook.MCAndroidFBIntegration.loginToFacebook(MCAn 
> droidFBIntegration.java:151)
>
> Can someone please help on this?
>
> Thanks,
> Kamal

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to