HI Guys I need to implement facebook login for my android application. I also use andengine, so I cannot use the login button provided by facebook. I also need the user's email address.
I created an action for this purpose called facebookActivity.
public class FacebookActivity extends BaseGameActivity{ private static final int CAMERA_WIDTH = 480; private static final int CAMERA_HEIGHT = 720; private Scene scene; private StatusCallback callback; @SuppressLint("NewApi") @Override public EngineOptions onCreateEngineOptions() { int SDK_INT = android.os.Build.VERSION.SDK_INT; if (SDK_INT>8){ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); return new EngineOptions(true, ScreenOrientation.PORTRAIT_SENSOR, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); } @Override public void onCreateResources( OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception { pOnCreateResourcesCallback.onCreateResourcesFinished();
When I run this code, I get a NullPointerException
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras) }} to activity {com.vocabtrainer.code/com.vocabtrainer.code.FacebookActivity}: java.lang.NullPointerException
I tried debugging and found that inside onActivityResult Session.getActiveSession () is NULL. but my application is actually posting to facebook and I allow you permission. Am I missing something? Guys please check
source share