I am trying to trap a share result from the Facebook share dialog using steps from the tutorial here and
vpires' solved thread here. He seemed to be able to trap the result by sending
ba.startActivityForResult(ion, null); without ever sending a requestcode or calling another intent for result.
My code is below, i just want to know that the post went through. But I get error: "onActivityResult: wi isnull" in my log after I send a post.
vpires' solved thread here. He seemed to be able to trap the result by sending
ba.startActivityForResult(ion, null); without ever sending a requestcode or calling another intent for result.
My code is below, i just want to know that the post went through. But I get error: "onActivityResult: wi isnull" in my log after I send a post.
B4X:
package cm.fb.share2;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.IOnActivityResult;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.share.Sharer;
import com.facebook.share.model.ShareLinkContent;
import com.facebook.share.widget.ShareDialog;
@ActivityObject
@DependsOn(values={"Facebooksdk410"})
@Permissions(values={"android.permission.INTERNET"})
@ShortName("fbcommand")
public class fbcommand {
public static IOnActivityResult ion;
int requestCode;
CallbackManager callbackManager;
ShareDialog shareDialog;
public void FbConnect(final BA ba, String Title, String Msg, String LinkUrl, String ImageUrl) {
FacebookSdk.sdkInitialize(BA.applicationContext);
ShareDialog shareDialog = new ShareDialog(ba.activity);
ion = new IOnActivityResult() {
@Override
public void ResultArrived(int resultCode, Intent intent) {
Log.d("B4A", "ResultsArrived");
if (resultCode == Activity.RESULT_OK) {
ba.raiseEvent(this, "fbfeed_complete", new Object[] { "OK" });
}
}
};
BA pba = ba.processBA;
try {
pba.startActivityForResult(ion, null); //<-- passing null instead of an intent
}
catch (NullPointerException npe) {
//required...
}
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(Title)
.setContentDescription(Msg)
.setImageUrl(Uri.parse(ImageUrl))
.setContentUrl(Uri.parse(LinkUrl))
.build();
shareDialog.show(linkContent);
}
}
}
Last edited: