Is it able to run firefox with parameters to my addon, which will execute suitable code? Or create callback for intent.startActivity from here https://github.com/cscott/skeleton-addon-fxandroid/blob/jni/bootstrap.js
This is a good question. Won’t Intent
s work? You can use JNI from addons -
https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/JNI.jsm
Also here is some examples of jni using intents -
https://github.com/cscott/intent-addon
Here is an example of Firefox using intents to launch a config page
// Opening a preference screen from JS.
let jenv;
try {
jenv = JNI.GetForThread();
let GeckoAppShell = JNI.LoadClass(jenv, "org.mozilla.gecko.GeckoAppShell", {
static_methods: [
{ name: "getContext", sig: "()Landroid/content/Context;" },
],
});
let Intent = JNI.LoadClass(jenv, "android.content.Intent", {
constructors: [
{ name: "<init>", sig: "(Landroid/content/Context;Ljava/lang/Class;)V" },
],
});
let GeckoPreferences = JNI.LoadClass(jenv, "org.mozilla.gecko.preferences.GeckoPreferences", {
static_methods: [
{ name: "setResourceToOpen", sig: "(Landroid/content/Intent;Ljava/lang/String;)V" },
],
});
let Context = JNI.LoadClass(jenv, "android.content.Context", {
methods: [
{ name: "startActivity", sig: "(Landroid/content/Intent;)V" },
],
});
let context = GeckoAppShell.getContext();
let intent = Intent["new"](context, GeckoPreferences);
// preferences_privacy is the resource name for the privacy screen.
// All the preferences resources are defined here:
// http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/resources/xml/
GeckoPreferences.setResourceToOpen(intent, "preferences_privacy");
context.startActivity(intent);
} finally {
if (jenv) {
JNI.UnloadClasses(jenv);
}
}
So basically you can set up to listen to intents.
Yes, I was able to open my activity, now from my activity I want to pass data back in my addon , how can I do that?
Setup your code to listen to intents. Then you can send it anything you want.
Yes, I used that code and opened my actvity successfuly, but now I want something like onActivityResult method in my addon. After closing my activity I want to get Data from it.