Cross platform NPAPI browser plugin.

Recently, I got chance to work on building NPAPI plugin. I've used few NPAPI plugin and had basic idea about what it is but didn't knew how to build one.

Primary use case for me was to make it run on Android and interact with a C++ service running in background. There is a sensor attached with Android based hardware and my task is to build a JavaScript SDK which allows developers to access this hardware sensor data via C++ service.

I started building a simple plugin using NPAPI SDK which has a function which can be invoked using JavaScript from Firefox running on Ubuntu. However, this focuses on building it for Linux.

After some digging, I was able to build it on Android (Gingerbread). But when I tried to load it on Emulator it wasn't working. Looks like a strange issue as it just doesn't register with browser on Android emulator.

 I posted my query on StackOverflow, but didn't come across anything useful. After trying some more I was able to resolve it by adding JNI interfaces for relevant entrypoints and it start working!

Next step is to separate OS specific interfaces so that this plugin can be built with platform specific code separate and sdk related code separately.

I hope this help anyone looking for building NPAPI plugin for Android, feel free to contact me in case you need any assistance.

Comments