Java Question Help with syntax...

DevBaby

Active Member
Licensed User
Longtime User
I am trying to use sample code for facebook's share dialog on their site https://developers.facebook.com/docs/sharing/android

Below is the code snippets I need

B4X:
public class MainActivity extends FragmentActivity {
    CallbackManager callbackManager;
    ShareDialog shareDialog;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FacebookSdk.sdkInitialize(getApplicationContext());
        callbackManager = CallbackManager.Factory.create();
        shareDialog = new ShareDialog(this);
        // this part is optional
        shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { ... });
    }


My question pertains to the shareDialog = new ShareDialog(this); statement. I have the following but I get an error for the ba.this reference. The error reads ba cannot be resolved to a type in the IDE.


B4X:
package cm.fb.share2;

import android.os.Bundle;
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 com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookSdk;
import com.facebook.share.Sharer;
import com.facebook.share.widget.ShareDialog;



@ActivityObject
@DependsOn(values={"Facebooksdk400"})
@Permissions(values={"android.permission.INTERNET"})
@ShortName("fbcommand")


public class fbcommand {

    public void FbConnectTest(final BA ba, String App_ID, String Msg, String Link, String Type) {

        FacebookSdk.sdkInitialize(BA.applicationContext);
        CallbackManager callbackManager = CallbackManager.Factory.create();
        ShareDialog shareDialog = new ShareDialog(ba.this);

    }

}
 

DonManfred

Expert
Licensed User
Longtime User
My question pertains to the shareDialog = new ShareDialog(this); statement. I have the following but I get an error for the ba.this reference. The error reads ba cannot be resolved to a type in the IDE.
Have you added the two b4a jars to your eclipseproject (Buildconfig)?
 
Top