0
 01-29 21:06:00.601: ERROR/AndroidRuntime(582): FATAL EXCEPTION: main
     java.lang.IllegalStateException: Could not execute method of the activity
     at android.view.View$1.onClick(View.java:2144)
     at android.view.View.performClick(View.java:2485)
     at android.view.View$PerformClick.run(View.java:9080)
     at android.os.Handler.handleCallback(Handler.java:587)
     at android.os.Handler.dispatchMessage(Handler.java:92)
     at android.os.Looper.loop(Looper.java:130)
     at android.app.ActivityThread.main(ActivityThread.java:3687)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:507)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
     at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:507)
     at android.view.View$1.onClick(View.java:2139)
     ... 11 more
     Caused by: java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that is not currently open.
     at com.facebook.Session.requestNewPermissions(Session.java:977)
     at com.facebook.Session.requestNewPublishPermissions(Session.java:501)
     at ***.MainActivity.postToFacebook(MainActivity.java:105)
     ... 14 more

例外はインラインでスローされます

 session.requestNewPublishPermissions(newPermissionsRequest);
 // Check for publish permissions
            List<String> permissions = session.getPermissions();
            if (!isSubsetOf(PERMISSIONS, permissions)) {
                pendingPublishReauthorization = true;
                Session.NewPermissionsRequest newPermissionsRequest = new Session
                        .NewPermissionsRequest(this, PERMISSIONS);


                session.requestNewPublishPermissions(newPermissionsRequest);


                Toast.makeText(getActivity().getApplicationContext(),
                        "Not enough permissions",
                        Toast.LENGTH_SHORT).show();
                return;
            }

この例外の意味と修正方法を教えてください。

4

3 に答える 3

1

Dmytro, as per my comment, I've put together a couple of articles which fully explain opening a Facebook session and requesting additional permissions: here and here. Hope you and others find it beneficial and save time getting started with the SDK! :)

Edit: The reason you are getting this exception is because you can't request new permissions on a non-open session. You need to open your session before requesting new permissions or making other Facebook API requests. I've put together a guide in the articles linked to above which ensure a Facebook API request (such as posting to a user's feed and so forth) is not made until the the user's session is open and the user has the required permissions.

于 2013-02-28T21:50:11.833 に答える
0

これは、アクセス許可を要求しているセッションが非アクティブ/期限切れであることを意味します。アクセス許可を要求する前に、セッションを再確立する必要があります。

于 2013-01-29T19:25:29.943 に答える
0

requestNewPublishPermissions を呼び出す前に、session.openForPublish(Session.OpenRequest openRequest) を呼び出しましたか?

于 2013-01-29T19:28:48.437 に答える