I'm trying to integrate Facebook SDK into an Android project. I'm posting a wall message in the Facebook Dialog, when I hit "Share", the message gets posted successfully on my Facebook wall. But my game still crashes!
I call it from my main class that extends Activity. To popup the facebook UI dialogs, I use runOnUiThread. (AsyncTask doesn't work in my code.)
public static int fbShareScores( final String sBody )
{
try
{
oThis.runOnUiThread (
new Runnable ( )
{
@Override
public void run ( )
{
Bundle params = new Bundle();
params.putString("caption", "Caption");
params.putString("description", sBody);
params.putString("picture", URL_TO_PNG);
params.putString("name", "Name");
oThis.mFacebook.dialog(oThis, "feed", params, null);
}
}
);
}
catch ( Exception e )
{
Log.d(Globals.sApplicationName, "share scores: Dialog: " + e.getMessage());
}
return 1;
}
Here are my errors from logcat:
D/Facebook-WebView(957): Webview loading URL: https://m.facebook.com/dialog/feed W/AudioFlinger(32): write blocked for 80 msecs, 275 delayed writes, thread 0xff88 D/dalvikvm(957): GC_CONCURRENT freed 539K, 15% free 7403K/8647K, paused 3ms+47ms D/webviewglue(957): nativeDestroy view: 0x925250 D/Facebook-WebView(957): Redirect URL: fbconnect://success?post_id=570020602_418386674846932 D/AndroidRuntime(957): Shutting down VM W/dalvikvm(957): threadid=1: thread exiting with uncaught exception (group=0x40014760) E/AndroidRuntime(957): FATAL EXCEPTION: main E/AndroidRuntime(957): java.lang.NullPointerException E/AndroidRuntime(957): at com.facebook.android.FbDialog$FbWebViewClient.shouldOverrideUrlLoading(FbDialog.java:143) E/AndroidRuntime(957): at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:219) E/AndroidRuntime(957): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:319) E/AndroidRuntime(957): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(957): at android.os.Looper.loop(Looper.java:126) E/AndroidRuntime(957): at android.app.ActivityThread.main(ActivityThread.java:3997) E/AndroidRuntime(957): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(957): at java.lang.reflect.Method.invoke(Method.java:491) E/AndroidRuntime(957): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) E/AndroidRuntime(957): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) E/AndroidRuntime(957): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager(67): Force finishing activity com.companyname.mainclassname/.MainClassName
The error is gone when I change the line in the above code to:
Then add a new DialogListener: