-
-
Save Noitidart/a67e7556027889070bb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment