Skip to content

SurfaceCallback API is missing #715

Closed

Description

@vautieri2

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.), .NET Android (net7.0-android, etc.)

Affected platform version

VS2022

Description

Xamarin.Android does not seem to provide a wrapper for https://developer.android.com/reference/androidx/car/app/SurfaceCallback

This API is used for Android Auto

Steps to Reproduce

Try to use SurfaceCallback in a Xamarin.Android project
-> Doesn't compile
Look at the Xamarin docs, (not mentioned)

Did you find any workaround?

No

Relevant log output

No response

Activity

  1. dellis1972 commented on Apr 5, 2023

    @dellis1972

    @moljac @jpobst looks like we are missing something in androidx? Should we move this issue over to that repo?

  2. jpobst commented on Apr 5, 2023

    @jpobst
    Contributor

    Xamarin.Android only provides bindings for Android's base framework android.jar. To use AndroidX API you need to add the relevant NuGet binding package.

    This API appears to be in this package:
    https://www.nuget.org/packages/Xamarin.AndroidX.Car.App.App

  3. vautieri2 commented on Apr 5, 2023

    @vautieri2
    Author

    I have 1.2.0.1 installed and have my app already working on their heads up display. I now need to add the surface callback. All I see exposed is ISurfaceCallback which does not have anything to override.

  4. jpobst commented on Apr 5, 2023

    @jpobst
    Contributor

    Looks like all the methods on the SurfaceCallback interface are default methods, which I don't think are currently exposed in AndroidX.

    Yep, let's move this issue to the AndroidX repository.

  5. transferred this issue fromdotnet/androidon Apr 5, 2023
  6. vautieri2 commented on Apr 5, 2023

    @vautieri2
    Author

    Just curious as I have no idea how long it takes to get a nuget with this fix. I can use a nightly build (I think I saw these somewhere) since we are not releasing this for over a month. Any way to do a short term work around?

  7. jpobst commented on Apr 10, 2023

    @jpobst
    Contributor

    There are some challenges to work through before packages can be updated to support default interface methods, so I would not expect them in the short term.

    You should be able to implement the needed methods in C# with the correct signature and mark them with the [Export] attribute to force the correct Java Callable Wrapper to be generated. (Documentation)

    This would look something like:

    public void MySurfaceCallback : Java.Lang.Object, ISurfaceCallback
    {
      [Export]
      public void OnSurfaceAvailable (SurfaceContainer surfaceContainer) { ... }
    }
  8. vautieri2 commented on Apr 14, 2023

    @vautieri2
    Author

    "This would look something like:" I'm getting surface callbacks now! So this seems to be a workaround.

  9. added a commit that references this issue on May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions