How to use @UsesAssets?

Do you have an idea as to how I can do this with @UsesAssets? Because I've tried and got nothing and no errors.

2 Likes

That's not particularly useful. Show some code and we can help you. The code I showed just opens the asset as an input stream. You still have to read the content.

No I was asking how I would bundle assets with my extension, it broke my project yesterday because of what I tried which was...

@UsesAssets(fileNames = "file.ttf") and @UsesAssets(fileNames = "assets/file.ttf")

But neither seemed to work.

see the annotation documentation https://docs.google.com/document/d/1UsjVC6bjf4rKPLP6FULUPeB6C8O-A5GbpYjvvwqTYK8/edit#heading=h.jk74mvj2s35x

see also the Map.java example from the App Inventor sources as example how to use it

@UsesAssets(fileNames = "location.png, marker.svg")

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

Those do not help me. Where do I place these assets?

I never used it up to know, but I think you put the assets into the subdirectory /assets of your extension
Taifun

Assuming your extension is MyExtension.java, create a folder called assets at the same level in the directory hierarchy and place your assets in it. Next, add the @UsesAssets annotation with the filenames (sans assets/). Lastly, use the Form's openAssetForExtension method to open the asset for reading. You can see an example of how we do this in the Look extension:

6 Likes