I wants to add custom XML in my extension. How can i use App inventor new feature @usesXML? No documentation is provided in this regard or if I am missing any can someone point me towards that? Thanks
Good question
The author @Patryk_F might want to provide an example and adjust the documentation at App Inventor Annotations - Google Docs
- Add a @UsesXml annotation for extension developers (@patryk84a)
Taifun
You're right, I'll do it when I find some time.
An example of use can be found here:
@UsesXmls(xmls = {
@XmlElement(dir = "xml",
name = "automotive_app_desc.xml",
content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<automotiveApp>\n<uses name=\"media\"/>\n</automotiveApp>")
})
This way we will add the file "automotive_app_desc.xml" to the folder "xml" in resources, with the content: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<uses name="media"/>\n"
We can add more xml files by adding subsequent elements after comma as below:
@UsesXmls(xmls = {
@XmlElement(dir = "xml",
name = "automotive_app_desc.xml",
content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<automotiveApp>\n<uses name=\"media\"/>\n</automotiveApp>"),
@XmlElement(dir = "drawable-anydpi-v3",
name = "icon_settings.xml",
content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:width=\"24dp\"\n android:height=\"24dp\"\n android:viewportWidth=\"960\"\n android:viewportHeight=\"960\">\n <path\n android:fillColor=\"@android:color/white\"\n android:pathData=\"M370,880L354,752Q341,747 329.5,740Q318,733 307,725L188,775L78,585L181,507Q180,500 180,493.5Q180,487 180,480Q180,473 180,466.5Q180,460 181,453L78,375L188,185L307,235Q318,227 330,220Q342,213 354,208L370,80L590,80L606,208Q619,213 630.5,220Q642,227 653,235L772,185L882,375L779,453Q780,460 780,466.5Q780,473 780,480Q780,487 780,493.5Q780,500 778,507L881,585L771,775L653,725Q642,733 630,740Q618,747 606,752L590,880L370,880ZM482,620Q540,620 581,579Q622,538 622,480Q622,422 581,381Q540,340 482,340Q423,340 382.5,381Q342,422 342,480Q342,538 382.5,579Q423,620 482,620Z\"/>\n</vector>")
})
We use annotations when we build an extension in app inventor sources or in extension-template (these haven't been updated yet). When using Fast you don't have to use annotations, just place the xml files in the appropriate project folders and enable the appropriate option in Fast.