我使用 asset-pack 库将一些资源打包到我的 Android kotlin 应用程序中:https://developer.android.com/guide/app-bundle/asset-delivery/build-native-java https://developer.android.com/guide/app-bundle/asset-delivery/build-native-java
不,我应该能够使用以下方式访问资产AssetManager
via context.assets
。但是,我不知道正确的道路是什么。
My assets pack is called models
and correctly created in the root folder of the .aab
file, so I guess it is also installed correctly.
现在根据文档(https://developer.android.com/guide/playcore/asset-delivery/integrate-java https://developer.android.com/guide/playcore/asset-delivery/integrate-java)我可以这样访问资产:
import android.content.res.AssetManager;
...
Context context = createPackageContext("com.example.app", 0);
AssetManager assetManager = context.getAssets();
InputStream is = assetManager.open("asset-name");
我将包名称更改为我的包名称。但资产名称是什么?!?这不是我的文件名models
资产文件夹。我试过assetManager.list(p)
with p
作为我能想到的任何东西,但我找不到我的资产存储在哪里。
For p=''
的结果assetManager.list(p)
is
hw_pc_white_apps.xml
hw_pc_white_apps_pad.xml
images
permission_grant_policy.xml
permission_grant_policy_oversea.xml
pfw
sfpconfig.json
ukeyapp.xml
water.frag
water.vert
webkit
wifi_policy.xml
wifipro_regexlist.xml
这对我来说也毫无意义。如何访问资源包中的资源?