Error at android compile time with foreign code

using Uno;
using Uno.Collections;
using Fuse;
using Fuse.Scripting;
using Uno.UX;

/*using global::Android.android.media;
using global::Android.android.app;
using global::Android.android.provider;
using global::Android.android.provider;
using global::Android.android.content;
using global::Android.java.util;*/

using Uno.Compiler.ExportTargetInterop;

[ForeignInclude(Language.Java, "java.lang.Runnable", "java.lang.Boolean", "android.app.*", "android.content.Intent",        "android.content.Context", "java.lang.*", )]
public class Calendar : NativeModule
{
static readonly Calendar _instance;
public Calendar()

{// Make sure we're only initializing the module once
    // Make sure we're only initializing the module once
    if (_instance != null) return;

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

object AddCalendar(Context c, object[] args)
{   
    
    AddCalendar(c, args);
    return null;
}

[Foreign(Language.Java)]
static extern(Android) void AddCalendar(Context context, string begin, string end)
@{
        java.util.Calendar cal = java.util.Calendar.getInstance(); 
        Intent intent = new Intent(Intent.ACTION_EDIT);
        intent.setType("vnd.android.cursor.item/event");
        intent.putExtra("beginTime", begin);
        intent.putExtra("allDay", true);
        intent.putExtra("rrule", "FREQ=YEARLY");
        intent.putExtra("endTime", end);
        intent.putExtra("title", "LIMITE FECHA DE PAGO");
        context.startActivity(intent);
        debug_log("Hecho");
@}
}    

I am trying to compile my .apk and I get this:

I have been stuck for hours with foreign code. What I want is to add an event to the calendar from JS, passing the start date and end date as parameters.

As the error says you don’t have context available. When doing foreign code you can get the Activity / Context as described here.

E.g. this should work: com.fuse.Activity.getRootActivity().startActivity(intent) :slight_smile: