How to access flutter assets from Java

浪子不回头ぞ 提交于 2021-02-11 12:22:35

问题


This code can be used to access flutter assets from Java:

String assetName = call.argument("asset");
String assetLookupKey = registrar.lookupKeyForAsset(assetName);
AssetFileDescriptor fd = registrar.context().getAssets().openFd(assetLookupKey);
player = new VideoPlayer(eventChannel, handle, fd, result);

However, how do I get registrar? I know FlutterActivity has this method:

registrarFor(String pluginKey)

But which key should I use? I'm not using any plugin, I'm trying to load the assets from my own app.

来源:https://stackoverflow.com/questions/65374762/how-to-access-flutter-assets-from-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!