请求facebook权限--NullPointerException

时间:2014-07-18 06:21:44

标签: java android facebook

我使用以下代码来请求" publish_actions"许可,

    private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
    private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
    private boolean pendingPublishReauthorization = false;  



                List<String> permissions = currentsession.getPermissions();
                    if (!isSubsetOf(PERMISSIONS, permissions)) {
                    pendingPublishReauthorization = true;

                    Session.NewPermissionsRequest newPermissionsRequest = new Session
                            .NewPermissionsRequest(this, PERMISSIONS);
                    System.out.println("insode"+newPermissionsRequest.toString());
                    currentsession.requestNewPublishPermissions(newPermissionsRequest);
                    return;
                }

但是我在这一行上得到了nullpointerexception

currentsession.requestNewPublishPermissions(newPermissionsRequest);

请查找错误日志

07-18 12:30:38.068: E/AndroidRuntime(23740): FATAL EXCEPTION: main
07-18 12:30:38.068: E/AndroidRuntime(23740): Process: com.test.app, PID: 23740
07-18 12:30:38.068: E/AndroidRuntime(23740): java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
07-18 12:30:38.068: E/AndroidRuntime(23740):    at android.app.Activity.startActivityForResult(Activity.java:3436)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at android.app.Activity.startActivityForResult(Activity.java:3393)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.facebook.Session$AuthorizationRequest$1.startActivityForResult(Session.java:1899)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.facebook.Session.tryLoginActivity(Session.java:1406)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.facebook.Session.authorize(Session.java:1156)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.facebook.Session.requestNewPermissions(Session.java:1261)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.facebook.Session.requestNewPublishPermissions(Session.java:592)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.fb.utils.Facebook_feedpost.publishStory(Facebook_feedpost.java:120)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.test.movieapp.WriteReview$2.onClick(WriteReview.java:224)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at android.view.View.performClick(View.java:4456)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at android.view.View$PerformClick.run(View.java:18462)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at android.os.Handler.handleCallback(Handler.java:733)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at android.os.Handler.dispatchMessage(Handler.java:95)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at android.os.Looper.loop(Looper.java:136)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at android.app.ActivityThread.main(ActivityThread.java:5102)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at java.lang.reflect.Method.invoke(Native Method)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-18 12:30:38.068: E/AndroidRuntime(23740):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

0 个答案:

没有答案