Description
Android framework version
net9.0-android
Affected platform version
Visual Studio Enterprise 2022 v17.13.1
Description
I am trying to create a class implementing the AndroidX.Media3.Session.MediaNotification.IProvider interface but the IProvider.CreateNotification() function signature doesn't appear to match the Android signature and it won't compile. This is what VS insists is the required declaration of the CreateNotification() function implementation...
public class MediaNotificationProvider : Java.Lang.Object, MediaNotification.IProvider
{
public bool HandleCustomCommand(MediaSession? p0, string? p1, Bundle? p2)
{
return true;
}
MediaNotification? MediaNotification.IProvider.CreateNotification(MediaSession? mediaSession, Java.Lang.Object? mediaButtonPreferences, MediaNotification.IActionFactory? actionFactory, MediaNotification.IProviderCallback? onNotificationChangedCallback)
{
throw new NotImplementedException();
}
}
... but when I try to compile this I get these two error messages...
obj\Debug\net9.0-android\android\src\crc64c44f8a9ee386df14\MediaNotificationProvider.java:4: error: MediaNotificationProvider is not abstract and does not override abstract method createNotification(MediaSession,ImmutableList<CommandButton>,ActionFactory,Callback) in Provider
public class MediaNotificationProvider
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
and
error: MediaNotificationProvider is not abstract and does not override abstract method createNotification(MediaSession,ImmutableList<CommandButton>,ActionFactory,Callback) in Provider
public class MediaNotificationProvider
According to the Android documentation the mediaButtonPreferences argument should be type ImmutableList<CommandButton> but trying the .net version of that doesn't work either and generates the error...
'MediaNotificationProvider.CreateNotification(MediaSession?, ImmutableList<CommandButton>?, MediaNotification.IActionFactory?, MediaNotification.IProviderCallback?)' in explicit interface declaration is not found among members of the interface that can be implemented
I am guessing the binding is not correct but I'm not familiar enough with .net Android bindings to understand what is going on.
Steps to Reproduce
- Right click on existing .net-android project and choose Add->New Item to create a new class
- Change class to inherit from Java.Lang.Object and MediaNotification.IProvider
- Start typing "MediaNotification.IProvider.Create" and then hit tab to accept the suggested code for CreateNotification()
- Attempt to build your code
Did you find any workaround?
No response