@UsesServices annotation

How am I able to use the @UsesServices annotation in my extension?

I've tried...

@UsesServices(services = {
  @ServiceElement(intentFilters = {
    @IntentFilterElement(actionElements = {
      @ActionElement(name = "the action name")
  }, label = "service name to be displayed to the user", name = "my package name and stuff")

Are you getting any error?
Or is it not working at all?

When I go into the manifest, it shows that the service has not been added. I didn't get any error in the console or while building.

@shreyash can you help me since you're the one who added it to App Inventor?

May I know where are you importing the extension? I mean in AI or other distros, like Kodular.


Kodular, but I can try AI. I'm wondering if with Kodular, it's more because of their recent patch?

It's possible that Kodular hasn't update with the latest version of App Inventor, which adds the support for @UsesServices. @Diego can you or one of your team comment on this?


Yes, you are right. We do not have @UsesServices in Kodular yet


@shreyash how do I reference the service from "name"... When I open my app, it crashes.

When I built an extension to test this functionality, I launched the service directly using a specific Android Intent rather than an IntentFilter (although I imagine you can adjust it). I can't seem to find my test code, but I think this is what you can do:

Intent intent = new Intent(form, MyService.class);

where form is the reference to the current form, which should be accessible in any non-visible extension, and MyService is the imported name of your service. You may want to include additional arguments in the intent bundle to be consumed in the service.