Annotation "UsesContentProviders"

Hi,

the new annotation UsesContentProviders for extensions is a long missed feature. Thank you for implementig it.

For one of my extensions I added an AssetFileProvider. To register this provider you have to add an UsesContentProviders annotation to the extension class. You also have to specify an authorities element to the ProviderElement. This element is fixed to the extension not to the app.

The problem is: Android does not like duplicate authorities entries. So having two apps using the same extension only the first one is installed. Android prohibits the installation of the second.

Is there a workaround?

Android Studio allows identifiers in braces inside manifest entries e.g. ${applicationId}. These are replaced when building the app. A similar function would help.

Kind regards
Ulrich

1 Like

Yes, there is. You can replace ${applicationId} with your app's package name. Though, this is not the most efficient way as you'll have to compile a new extension for every app.

Note: Package name of AI2 apps looks like this -- appinventor.ai_<your_email_without_@sth.com>.<YourAppName>.

1 Like

There is no way to do this currently. However, this PR introduced a %type% token for use in component descriptions. A similar thing can be implemented for the annotations too, like %packageName% which will allow you to have unique content providers for each app.

2 Likes

See https://github.com/mit-cml/appinventor-sources/pull/2315

1 Like