- Home /
Unity FBConnect Integration
Hey Answers,
Currently, I'm on a project where I need to integrate facebook sharing into our game. I finally figured out how to create a independent app on the android where I can just simply post (Used Eclipse). Now I am currently stuck trying to do the same thing except though c# using that same code as a java plugin.
So I separated them out into...
public void shareGame()
{
facebook.authorize(this/*Problem is here! It requies a Activity*/, new DialogListener() {
@Override
public void onComplete(Bundle values) {
Log.d("Boomblastica","fb called");
Bundle bd = new Bundle();
//bd information added here...
facebook.dialog(mContext, "feed", bd, new PostDialogListener());
}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {
}
});
}
a simple method to send a post to facebook but it just throws errors about Looper.prepare() before this. Tried it... didn't work.
I also thought of changing the whole class into extending from nothing but that won't work because the FBConnect requires the context and the activity (Unless there is a way to grab those information without the class extending from an Activity).
I also tried just sending null through since XCode version allowed it but this version it did not.
For the C# side,
private static AndroidJavaObject jo = new AndroidJavaObject("/*reference here*/");
public static void ShareGame()
{
if(Application.platform == RuntimePlatform.Android)
{
Debug.Log("Should be sharing");
jo.Call("shareGame");
}
}
to call the function that's in java. If I don't integrate any FB stuff it runs the Log.d's fine. So I know C# is finding the class it just won't do anything with the FB integration because of the Activity/Context stuff...
Thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220613061900im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do you access a custom Java class from Unity? 1 Answer
Problem in android java plugin 0 Answers
Send message to Java Code (without a plugin)? 1 Answer
Calling static jar function from Unity3D 0 Answers
Compass java plugin for Unity Android 4 Answers