Start a new topic

Communication between Javascript and Android

Communication between Javascript and Android


I'd like to know how I can call an Activity method from javascript (with parameters).

Thank you very much in advance.

Try something like this:



function runMethod()


   document.location = "architectsdk://runMethod?param1="+value1+"&param2="+value2;  





public boolean urlWasInvoked(String url) {

//parsing the retrieved url string

List<NameValuePair> queryParams = URLEncodedUtils.parse(URI.create(url), "UTF-8");


String param1 = "";

String param2 = "";

// getting the values of the contained GET-parameters

for(NameValuePair pair : queryParams)




      param1 = pair.getValue();




      param2 = pair.getValue();




//run method with parameters


return true;


Thank you very much! 

I'll try the code and then I'll tell you if it worked.

Done! The process to call Android method from JavaScript is:

1.- Your activity must implement the method of the interface 'ArchitectUrlListener'.

2.- In that method (urlWasInvoked) you get the data as Bartosz described.

3.- From Javascript you just call that method with something like this: document.location = "architectsdk://metodoEnAndroid?param1=10&param2=20";


I suppose this will be usefull for more people!

1 person likes this
Login or Signup to post a comment