Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess Assests from another application?
    primarykey
    data
    text
    <p>I get a lot of requests in my application to allow for custom icons packs from BetterCut / Open Home. The way it seems to work is you install BetterCut or Open Home, then you can install tons of these free icon packs from the market. Once installed both those apps (and other apps) will poll for those icon packs and use the icons. </p> <p>I want to know how to poll the install applications for the asset folders that are available. I have opened up a few of the icon packs and verified that there is an assets folder in there and they are full of all the icon png files.</p> <p>I've searched on here, other code sites, google, etc but havn't found any leads.</p> <p>UPDATE:</p> <p>From the answer below I have written some code to try and list a file from my own projects assets directory but it does not seem to work.</p> <pre><code>Resources r = this.getResources(); AssetManager a = r.getAssets(); String[] list = a.list("/"); Log.d("test", "Length of / is "+list.length); for (String s : list) { Log.d("test", s); } Log.d("test", "Length of /assets is "+a.list("/assets").length); Log.d("test", "Length of /assets/ is "+a.list("/assets/").length); Log.d("test", "Length of /assets/ is "+a.list("/assets/").length); Log.d("test", "Length of ./assets/ is "+a.list("./assets/").length); Log.d("test", "Length of ./assets is "+a.list("./assets").length); </code></pre> <p>This is the output:</p> <pre><code>03-16 12:25:04.591: DEBUG/test(13526): Length of / is 6 03-16 12:25:04.591: DEBUG/test(13526): AndroidManifest.xml 03-16 12:25:04.591: DEBUG/test(13526): META-INF 03-16 12:25:04.591: DEBUG/test(13526): assets 03-16 12:25:04.591: DEBUG/test(13526): classes.dex 03-16 12:25:04.591: DEBUG/test(13526): res 03-16 12:25:04.591: DEBUG/test(13526): resources.arsc 03-16 12:25:04.614: DEBUG/test(13526): Length of /assets is 0 03-16 12:25:04.637: DEBUG/test(13526): Length of /assets/ is 0 03-16 12:25:04.661: DEBUG/test(13526): Length of /assets/ is 0 03-16 12:25:04.692: DEBUG/test(13526): Length of ./assets/ is 0 03-16 12:25:04.716: DEBUG/test(13526): Length of ./assets is 0 </code></pre> <p>UPDATE 2 99% There!!!:</p> <p>I figured out that you can read from the assets directory without actually using the folder name:</p> <pre><code>InputStream is = assetManager.open("test.png"); </code></pre> <p>I also tried this with an asset in Appliction 2 from Application 1, where the folder path is /asset/icon/image.png:</p> <pre><code>InputStream is = assetManager.open("icon/image.png"); </code></pre> <p>Next I figured out that you can list a directory inside assets:</p> <pre><code>String[] list = assetManager.list("icons"); </code></pre> <p>That also works great. The only thing failing right now is how to list the base directory assets.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload