Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Function ignored due to ignored param #755

Open
AndyNetDuma opened this issue Jan 29, 2020 · 1 comment
Open

Function ignored due to ignored param #755

AndyNetDuma opened this issue Jan 29, 2020 · 1 comment
Milestone

Comments

@AndyNetDuma
Copy link

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

@chamons chamons added this to the Future milestone Jan 29, 2020
@AndyNetDuma
Copy link
Author

Is there a workaround I can use while waiting for this to be fixed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants