为什么原生编译失败但没有C#报错(NotificationManager继承)

Why native compilation failed but no C# error (NotificationManager inheritance)

我有这个代码:

public class myNotificationManager : NotificationManager
{
    protected myNotificationManager(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
    {

    }
}

我Visual Studio没有错误。 但是当我构建项目时出现此错误:

error: constructor NotificationManager in class NotificationManager cannot be applied to given types;
public class myNotificationManager
  required: Context,Handler
  found: no arguments
  reason: actual and formal argument lists differ in length App2    
  C:\Workspaces\Sandbox\App2\App2\obj\Debug\android\src\crc64bb1b55f618e11607\myNotificationManager.java

我理解消息,但根据 dotnet 文档:NotificationManager Constructor 构造函数参数的类型是 IntPtrJniHandleOwnership 不是 ContextHandler.

来自 the Android documentation 我没有看到任何 public 构造函数

好像错误消息中显示的 class 版本与我在 IDE

中看到的版本不同

Android 目标框架版本:v9.0 (API 28)

Android 已安装 SDK 平台:28,29,30

如果你想收到通知,

            NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "Main")
                .SetSmallIcon(Android.Resource.Drawable.IcDialogAlert)
                .SetContentTitle("Title")
                .SetContentText("Text")
                .SetPriority((int)NotificationPriority.High);

            NotificationManagerCompat manager = NotificationManagerCompat.From(context);
            manager.Notify(10, builder.Build());

但不知道是不是通知构造函数的问题