You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.
I am trying to get callbacks working from C# to Android kotlin.
I have the following classes.
[Register("hello_from_csharp.Class1")]
public class Class1
{
public int count = 0;
[Export("aStringFunction")]
public string aStringFunction()
{
return "Hello from C#";
}
[Export("startLoop")]
public void StartLoop(JavaCallback callback)
{
Task.Run(() =>
{
while (true)
{
callback.Callback(count++.ToString());
Thread.Sleep(500);
}
});
}
}
[Register("hello_from_csharp.JavaCallback")]
public abstract class JavaCallback : Java.Lang.Object
{
public JavaCallback() { }
public JavaCallback(IntPtr handle, JniHandleOwnership transfer) : base(handle, transfer) { }
[Export("Callback")]
public abstract void Callback(string data);
}
I have successfully created Class1 and called aStringFunction from kotlin. However StartLoop never makes it into the library. Looking at the build logs it says 'StartLoop' was ignored due to ignored param
Also worth noting, I was able to create the an instance of JavaCallback with the overload so JavaCallback itself makes it in.
var j = object : JavaCallback()
{
override fun Callback(p0: String?) {
someText.text = p0;
}
}
I have been following this guide from Microsoft however it was written in 2017 so maybe things have changed since.
So in short why is StartLoop being removed and is there a better way to implement callbacks now?
If it helps I have attached a full build log. buildLog.txt
The text was updated successfully, but these errors were encountered:
I am trying to get callbacks working from C# to Android kotlin.
I have the following classes.
I have successfully created Class1 and called aStringFunction from kotlin. However StartLoop never makes it into the library. Looking at the build logs it says
'StartLoop' was ignored due to ignored param
Also worth noting, I was able to create the an instance of JavaCallback with the overload so JavaCallback itself makes it in.
I have been following this guide from Microsoft however it was written in 2017 so maybe things have changed since.
So in short why is StartLoop being removed and is there a better way to implement callbacks now?
If it helps I have attached a full build log.
buildLog.txt
The text was updated successfully, but these errors were encountered: