I need send some data from firefox extension to native android application. How can I use intent for this? Is it an api in firefox for this action? Thanks
-
I'm confused. Is this from the android version of firefox? – matt5784 Oct 07 '12 at 19:13
-
Sorry! Android 4.0.3 and firefox 15.0.1 (for android). I need send data from firefox to another android application. – izumeroot Oct 07 '12 at 20:08
2 Answers
This is now possible using as an example the code in this add-on
Its done in a very neat way using JNI to access the Android intents Java classes via Firefoxes C++ code.

- 7,562
- 6
- 43
- 65
-
1Struggling with the section "hacky way to get activity context" in the add-on main.js code (causes firefox mobile crash). What is the reason? – Mmh Aug 08 '14 at 05:50
-
This is super cool, do you have any other work based on this Maks or @mmh to share? – yatg Jul 10 '15 at 16:46
-
Heres a copy paste example that works: https://github.com/mozilla/firefox-for-android-addons/blob/355f9a01464a0794c1084e8fdbab92c58503f49a/snippets/jni.js#L23-L44 – Noitidart Jul 11 '15 at 09:33
I don't think you can. Firefox for Android consists of two parts: the Gecko browser engine (native binary, same as for the desktop Firefox) and the Java-based user interface (Android-specific). The two parts are largely independent and communicate via messaging. Extensions run in Gecko, only the Java-based part can use intents however. I looked at the messages that these two parts can exchange and they are all very specific and related to particular browser actions, nothing that would allow using a generic intent.
If the native application is already running you might be able to communicate via TCP sockets. Either the extension or the native application would need to open a server socket on a well-known port that the other party would connect to.

- 1
- 1

- 56,865
- 12
- 98
- 126
-
Thanks! Is there ability send data in command line params? For example, I will send my data like this - `target_programm my_data_sting` Will it work if android application started already? – izumeroot Oct 09 '12 at 13:51
-
@izumeroot: Don't know, try it? Starting a process should work on Android exactly the same as on desktop. What happens if you start a second instance of your application normally depends on your application - it needs to find the first instance and communicate back to it. – Wladimir Palant Oct 09 '12 at 14:00
-
A communication with first instance i can do via sockets also? Then I don't see sence in command line param. – izumeroot Oct 09 '12 at 14:12