Assets - “images”, “sounds”, and “webkit”?

2020-07-10 06:43发布

I am trying to get recursively load all the assets I have placed within the "assets" folder within my project. When I do the following:

AssetManager assetManager = getResources().getAssets();
String assets[] = assetManager.list("");

and the check what strings were loaded into the assets array, I find the assets I have placed within the specified folder, along with the strings "images", "sounds", and "webkit". Does anyone know why this is?

For background information (don't yet know if it is applicable), my assets are zip files that contain complete html webpages, which I use to load into WebViews.

标签: android
3条回答
在下西门庆
2楼-- · 2020-07-10 07:25

In my case, I was creating the assets folder inside the "app" directory of the project (app -> assets), and the files I loaded into this "assets" folder were not being read by the AssetsManager. Then I right clicked on the "app" folder -> New -> Folder -> Assets Folder (location "main") and everything was resolved. The problem was with the location where the "assets" folder was being created.

查看更多
▲ chillily
3楼-- · 2020-07-10 07:30

i had this problem and i suggest you check couple of things:

  1. the directory name is written in english. \n
  2. you have just one directory in your assets root (in this one directory you can insert couple of drectories).
    for example:
    assets->app->image, assets->app->another dir.
    in this example the app dir is the only dir in the asssete root.
查看更多
等我变得足够好
4楼-- · 2020-07-10 07:32

I also have noted this. Here are some assets that are placed in those directories:

webkit/play.png
webkit/nullPlugin.png
webkit/missingImage.png
webkit/android-weberror.png
sounds/bootanim1.raw
images/comobox-disabled.png
images/comobox-noHighlight.png 

My guess is that system relies on this assets to be present in all .apk files. But instead of building them in (which would increase size of all .apk files), Android emulates them via asset API.

Also, as a side-effect, you can override this assets with any custom asset that has same name as built-in one. Not that this may be too useful, but this is possible.

查看更多
登录 后发表回答