Mozilla's getting a new look. What do you think? https://mzl.la/brandsurvey

JavaAddonManager.jsm

The JavaAddonManager object is only available to privileged code running on Firefox for Android, and is intended for use by Firefox for Android add-ons.

Mobile Only in Gecko 41
Available only in Firefox Mobile as of Gecko 41 (Firefox 41 / Thunderbird 41 / SeaMonkey 2.38)

JavaAddonManager Summary

The JavaAddonManager API lets you dynamically load compiled Java code and interact with it.  JavaAddonManager is a single object that provides a Promise-based API.  JavaAddonManager is a factory that produces JavaAddonV1 instances.

JavaAddonManager Method Overview

Promise classInstanceFromFile(classname, filename)

JavaAddonManager Methods

classInstanceFromFile()

Instantiate a Java Addon class from a file.

Promise classInstanceFromFile(
  in string classname,
  in string filename
)
Return value

Returns a Promise that resolves to a JavaAddonV1 if we could instantiate a Java Addon class named classname from the file named filename.

Parameters
classname
A fully qualified Java Addon class name, like "com.company.somepackage.Class".  The specified Java Addon class need not extend a particular class or implement a particular interface, but it must expose a public constructor with the signature:
public class Class {
  public Class(
    android.content.Context context,
    org.mozilla.javaaddons.JavaAddonInterfaceV1.EventDispatcher eventDispatcher
  )
}
filename
Path to a classes.dex (or archive containing a classes.dex file).  filename can be a:
  • path to a .dex, like "/mnt/sdcard/classes.dex";
  • path to a .jar or .apk file containing a "classes.dex" file;
  • Gecko file:// URI to such a file, like "file:///mnt/sdcard/classes.dex";
  • Gecko chrome:// URI to such a file, like "chrome://myaddon/content/classes.dex";
  • Gecko resource:// URI to such a file, like "resource://android_assets/classes.dex".

JavaAddonV1 Summary

JavaAddonV1 instances provide a messaging interface to instantiated Java Addon classes.

JavaAddonV1 Method Overview

void sendRequest(message)
Promise sendRequestForResult(message)
void addListener(listener, message)
void removeListener(message)

JavaAddonV1 Methods

 

sendRequest()

Send a message to the underlying Java Addon class.  Your Java Addon class can handle this request by following the INSTRUCTIONS HERE. (XXX link).

void sendRequest(
  in object message
)
Return value

None.

Parameters
message
A message object in the format expected by Messaging.jsm.  Must have a type parameter.

sendRequestForResult()

Send a message to the underlying Java Addon class, and expect a response.  Your Java Addon class can handle this request by following the INSTRUCTIONS HERE. (XXX link).

void sendRequestForResult(
  in object message
)
Return value

Returns a Promise that resolves to the result.

Parameters
message
A message object in the format expected by Messaging.jsm.  Must have a type parameter.

addListener()

Start listening for a message from the underlying Java Addon class. Your Java Addon class can message to this listener by following the INSTRUCTIONS HERE. (XXX link).

void addListener(
  in function listener,
  in string message
)
Return value

None.

Parameters
listener
Listener function. This function will be called with the (JSON) object provided by your Java Addon class.
message
String identifying message to start listening for. It is an error to listen to the same message twice.

removeListener()

Stop listening for a message from the underlying Java Addon class.

void removeListener(
  in string message
)
Return value

None.

Parameters
message
String identifying message to stop listening for.

Document Tags and Contributors

 Contributors to this page: wbamberg, lmandel, nalexander
 Last updated by: wbamberg,