JS return android ID

Nick Alexander nalexander at mozilla.com
Tue May 20 09:28:25 PDT 2014


On 2014-05-20, 7:21 AM, Benson Chen wrote:
> Hi All
>
> I want to add one feature for Fence, which use JS to return
> Settings.Secure.ANDROID_ID
> <http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID>.
>
> Should I develop one Add on or add one module in Fence?  Can anyone give
> some hits to me?

By Fence, I assume you mean Fennec, the name we use for Firefox for 
Android.  If Fence is something else (an add-on?  a consumer of 
GeckoView?), this won't correct.

In general, to expose something from the Android platform to the Fennec 
JS platform, you must implement an add-on.  Your add-on can either:

1) use JavaAddonManager to load DEXed Java bytecode that returns the 
Android value;

2) or use the built-in JNI.jsm module to extract the value from the 
Android platform.

I'm not aware of examples of 1), although I've built one myself.  If 
anybody knows of such an example on github, do say.  There are lots of 
examples of 2), including 
https://github.com/ncalexan/healthreport-upload-test-addon.

Nick


More information about the mobile-firefox-dev mailing list