Loading webkit plugins in WebView

558 views
Skip to first unread message

jihoon

unread,
Aug 26, 2009, 1:28:45 AM8/26/09
to android-platform
Hi,

I'm trying to load a webkit plugin (.so file) through WebView /
WebSettings API.
For test purpose, I am using browsertestplugin.so. (which I found in
platform source at "external/webkit/WebKit/android/plugins/sample" and
also in 1.5 image in /system/lib/browsertestplugin.so)

First, I made a simple webpage which embeds 'type="application/x-
testplugin"' tag and loaded it in android browser. This did not
work. After an hour of googling, found out that I need to put
browsertestplugin.so in /data/data/com.android.browser/app_plugins/.
Then, the plugin successfully loaded and showed little red ball
bouncing on wall. Great.

Now, when I try to do the same thing in my own Activity using WebView
class, I don't think this works.
I've placed browsertestplugin.so in "/sdcard/plugins" so that my code
can read & load it.
Following is what I used to load the plugin and the page containing
application/x-testplugin stuff.
-------------------
WebView webview = new WebView(this);
websettings = webview.getSettings();

websettings.setPluginsEnabled(true);
websettings.setPluginsPath("/sdcard/plugins/");
websettings.setAllowFileAccess(true);

webview.refreshPlugins(true);

Log.d("WebViewDemoActivity", "PluginsEnabled: " +
websettings.getPluginsEnabled());
Log.d("WebViewDemoActivity", "PluginsPath: " +
websettings.getPluginsPath());

for (Object o : WebView.getPluginList().getList()) {
Plugin p = (Plugin)o;
Log.d("WebViewDemoActivity", "PluginFileName: " +
p.getFileName());
}
----------------
This did not print any plugin list. (WebView.getPluginList().getList()
returned 0-sized list)

Next, I tried loading the so file directly and constructing Plugin
object manually and adding it to PluginList.
----------------
Plugin pp = new Plugin("Test", "/sdcard/plugins",
"browsertestplugin.so", "Test Plugin");

WebView.getPluginList.addPlugin(pp);
----------------
After this, I could see the "browsertestplugin.so" in
WebView.getPluginList().
However, the site still did not render properly in my WebView (still
showing the blue "no-plugin" icon)

Now I'm stuck and don't know what to do. Any pointers to what the
problem is or what I'm doing wrong would be great.

jihoon

unread,
Aug 26, 2009, 4:55:08 AM8/26/09
to android-platform
I just solved this issue. (digging up in android browser app's java
source)

Instead of "/sdcard", I put the plugin .so file in app's own data dir.
(For example, somewhere in '/data/data/com.example/xxx')
Then, webview.setPluginsPath('/data/data/com.example.xxx' works
perfectly.
(Must have been some kind of permissions issue?)
Reply all
Reply to author
Forward
0 new messages