Search code examples
androidandroid-ndknpapi

How to access res and assets in the apk of browser plugin?


I am writing a browser plugin on Android. However, I don't know how to access res and assets in the plugin apk.

I tried to print out R and path in the java code of my plugin, but I got the results from browser (not from plugin).

For example:

ApplicationInfo appInfo = context.getApplicationInfo();
Log.i("(test)", "path = " + appInfo.dataDir);

Its output is /data/data/com.android.browser , but I want to access the path: /data/data/com.test.myplugin .

Any suggestion is welcome and thanks in advance.

PS: I have traced the example code of development/samples/BrowserPlugin .


Solution

  • I find the solution. The root cause is this context from browser, so its res and assets are also from browser. The solution is to use package manager to access original plugin's apk, and then I can get the correct res and assets.