How to access Native Android code from uno

#1

I am trying to tie in native android code into fuse but I am having trouble accessing native java from uno. Here is my code below:

[UXGlobalModule]
public class VoiceCall : NativeModule
{
static readonly VoiceCall _instance;

public VoiceCall()
{
    if(_instance != null)
        return;

    _instance = this;
    Resource.SetGlobalKey(_instance, "VoiceCall");
    AddMember(new NativeFunction("startVoiceCall", (NativeCallback)startVoiceCall));
}

object startVoiceCall(Context c, object[] args)
{
    VoiceCallImpl();

    return null;
}

[Foreign(Language.Java)]
extern(android) void VoiceCallImpl()
@{
	Activity a = com.fuse.Activity.getRootActivity();
	Intent intent = new Intent(a, VoiceChatViewActivity.class);
	a.startActivity(intent);
@}

}

When I try to run it I get the following error:

Error E3102: There is nothing named ‘VoiceCallImpl’ accessible in this scope. Are you missing a package reference?1.18 s.

Its as though uno cannot access the java function even though its defined within the same class. How do I solve this?

0 Likes

#2

I just found out that running build from the command line as opposed to fuse studio runs the code well :stuck_out_tongue:

0 Likes

#3

The desktop preview can’t run native code, you have to test on device for that.

0 Likes