This is my first attempt at Uno/Foreign code. Was testing the android toast implementation and actually go it working with hardcoded message. Now, i am trying to pass the message as parameter to be displayed and i’m not making head way . i keep getting these
"No overloads of 'ToastIt' matches the argument list (string)
Candidates are: myToast.ToastIt(Fuse.Scripting.Context,object[])
myToast.ToastIt()
See code below.
using Uno;
using Uno.Collections;
using Fuse;
using Fuse.Scripting;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;
[extern(Android) ForeignInclude(Language.Java, "android.app.Activity","android.widget.Toast")]
[UXGlobalModule]
public class myToast : NativeModule
{
public myToast(){
AddMember(new NativeFunction("toastIt", (NativeCallback)ToastIt));
}
static object ToastIt(Fuse.Scripting.Context c, object[] args)
{
var arg = args[0] as string;
myToast.ToastIt(arg);
debug_log(arg);
return null;
}
[Foreign(Language.Java)]
static extern(Android) void ToastIt(string message)
@{
final android.app.Activity context = com.fuse.Activity.getRootActivity();
context.runOnUiThread(new Runnable(){
public void run(){
Toast.makeText(context ,message,Toast.LENGTH_LONG).show();
}
});
@}
static extern(!Android) void ToastIt()
{
debug_log("Toast not supported on this platform.");
}
}
And the javascript
var myToast = require("myToast");
myToast.toastIt("Hello World");