我想要超出用户的照片和相册
我的代码是:
Session session;
private Session.StatusCallback statusCallback;
@Override
protected void onCreate(Bundle savedInstanceState) {
session = new Session(getApplicationContext());
statusCallback = new SessionStatusCallback();
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
if(!session.isOpened() && !session.isClosed()){
session.openForRead(new Session.OpenRequest(this)
.setPermissions(Arrays.asList("user_photos"))
.setCallback(statusCallback));
}else{
Session.openActiveSession(FbGallery.this, true, statusCallback);
}
}
private class SessionStatusCallback implements Session.StatusCallback {
@Override
public void call(final Session session, SessionState state, Exception exception) {
if (session.isOpened() && session!=null)
{
if (session.isOpened()) {
Request.executeMeRequestAsync(session, new Request.GraphUserCallback()
{
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
gallery(session);
}
}
});
}
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
我猜代码中的一切都很好,但为什么这个错误显示::
E/AndroidRuntime(18633): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras) }} to activity {jsoft.projects.photoprint_v1_1/jsoft.projects.photoprint_v1_1.FbGallery}: java.lang.NullPointerException
堆栈跟踪
05-01 12:34:30.081: E/AndroidRuntime(19178): FATAL EXCEPTION: main
05-01 12:34:30.081: E/AndroidRuntime(19178): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras) }} to activity {jsoft.projects.photoprint_v1_1/jsoft.projects.photoprint_v1_1.FbGallery}: java.lang.NullPointerException
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.app.ActivityThread.deliverResults(ActivityThread.java:3500)
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3543)
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.app.ActivityThread.access$1200(ActivityThread.java:159)
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.os.Looper.loop(Looper.java:176)
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.app.ActivityThread.main(ActivityThread.java:5419)
05-01 12:34:30.081: E/AndroidRuntime(19178): at java.lang.reflect.Method.invokeNative(Native Method)
05-01 12:34:30.081: E/AndroidRuntime(19178): at java.lang.reflect.Method.invoke(Method.java:525)
05-01 12:34:30.081: E/AndroidRuntime(19178): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
05-01 12:34:30.081: E/AndroidRuntime(19178): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
05-01 12:34:30.081: E/AndroidRuntime(19178): at dalvik.system.NativeStart.main(Native Method)
05-01 12:34:30.081: E/AndroidRuntime(19178): Caused by: java.lang.NullPointerException
05-01 12:34:30.081: E/AndroidRuntime(19178): at jsoft.projects.photoprint_v1_1.FbGallery.onActivityResult(FbGallery.java:154)
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.app.Activity.dispatchActivityResult(Activity.java:5563)
05-01 12:34:30.081: E/AndroidRuntime(19178): at android.app.ActivityThread.deliverResults(ActivityThread.java:3496)
05-01 12:34:30.081: E/AndroidRuntime(19178): ... 11 more