AddUObject when function takes bool?

Hey i am trying to get call back functions from java to work (GameActivity.java).

I have been able to successfully do this when the callback takes no parameters but cannot figure out the correct way to define it when the function returns a bool.

GameActivity.java


public native void nativeMyCallbackFunc(boolean myReturnVal);

AndroidJNI.h


DECLARE_MULTICAST_DELEGATE_OneParam(FOnMyCallbackFunc, jboolean);
class FJavaWrapper
{
.....
static FOnMyCallbackFunc OnMyCallbackFunc;


AndroidJNI.cpp



FOnMyCallbackFunc JavaWrapper::OnMyCallbackFunc;

.....

extern "C" void Java_com_epicgames_ue4_GameActivity_nativeMyCallbackFunc(jboolean myReturnVal)
{
	FJavaWrapper::OnMyCallbackFunc.Broadcast(myReturnVal);
}


MyActor.h



	UFUNCTION(BlueprintNativeEvent, Category = "MyEvents")
	void OnMycallbackFunc(bool myReturnVal);

	void OnMycallbackFunc_Implementation(bool myReturnVal);


MyActor.cpp



void AMyActor::BeginPlay()
{
.....
FJavaWrapper::OnMyCallbackFunc.AddUObject(this, &AMyActor::OnMycallbackFunc);
}


It doesn’t like the AddUObject part and i think it is to do with the bool but i’m not sure how to define it as if i do a function callback with no paramaters using



DECLARE_MULTICAST_DELEGATE(FMycallbackFunc);


and AddUObject as above it works and fires off when used in blueprint.

Thanks

If you need to have a return value or any output parameters, you can’t use a multicast delegate. Multicasts can be bound to multiple callbacks simultaneously, so it doesn’t make sense to have return values.
Try declaring it with DECLARE_DELEGATE instead.

Also, I don’t know much about java and if it passes booleans by reference by default, but in C++ if you want to pass the value back to the caller, it needs to be either a return value, or a reference parameter.

your delegate is declared to take jboolean while OnMycallbackFunc takes bool, try and convert one way or the other so they are the same

Thanks man changed my declare to take a bool and cast the jboolean. All is working now.