2つのボタンを持つアクティビティがあります
- フェイスブックにログインするためのものです。ログイン後、そのアクティビティを終了します
- その他のボタンは壁に投稿するためのものです
最初の部分はOKでしたが、2番目の部分ではFacebookのサンプルを参照し、次のようにオープンセッションに投稿許可を追加しようとしました
private void performPublish(PendingAction action) {
Session session = Session.getActiveSession();
if (session != null) {
pendingAction = action;
if (hasPublishPermission()) {
// We can do the action right away.
handlePendingAction();
} else {
// We need to get new permissions, then complete the action when we get called back.
session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, PERMISSIONS));
}
}
}
しかし、次のエラーが発生しました
04-14 16:49:18.760: E/AndroidRuntime(2529): FATAL EXCEPTION: main
04-14 16:49:18.760: E/AndroidRuntime(2529): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartcloud/com.smartcloud.HelloFacebookSampleActivity}: java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1751)
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.os.Handler.dispatchMessage(Handler.java:99)
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.os.Looper.loop(Looper.java:132)
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.app.ActivityThread.main(ActivityThread.java:4028)
04-14 16:49:18.760: E/AndroidRuntime(2529): at java.lang.reflect.Method.invokeNative(Native Method)
04-14 16:49:18.760: E/AndroidRuntime(2529): at java.lang.reflect.Method.invoke(Method.java:491)
04-14 16:49:18.760: E/AndroidRuntime(2529): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
04-14 16:49:18.760: E/AndroidRuntime(2529): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
04-14 16:49:18.760: E/AndroidRuntime(2529): at dalvik.system.NativeStart.main(Native Method)
04-14 16:49:18.760: E/AndroidRuntime(2529): Caused by: java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.
04-14 16:49:18.760: E/AndroidRuntime(2529): at com.facebook.Session.requestNewPermissions(Session.java:968)
04-14 16:49:18.760: E/AndroidRuntime(2529): at com.facebook.Session.requestNewPublishPermissions(Session.java:501)
04-14 16:49:18.760: E/AndroidRuntime(2529): at com.smartcloud.HelloFacebookSampleActivity.performPublish(HelloFacebookSampleActivity.java:194)
04-14 16:49:18.760: E/AndroidRuntime(2529): at com.smartcloud.HelloFacebookSampleActivity.onClickPostStatusUpdate(HelloFacebookSampleActivity.java:161)
04-14 16:49:18.760: E/AndroidRuntime(2529): at com.smartcloud.HelloFacebookSampleActivity.onCreate(HelloFacebookSampleActivity.java:89)
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
04-14 16:49:18.760: E/AndroidRuntime(2529): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
04-14 16:49:18.760: E/AndroidRuntime(2529): ... 11 more
私を助けてください!それは私にとって本当にとても重要です