Thursday, January 17, 2013

javascript to android injection


step 1 ) register you class with an interface , open eclipse project and write

Launchs _accessors = new Launchs();

 web.addJavascriptInterface(new Launchs(), "test_callback");

this will register interface


now define your class

class Launchs{
              
            public void nativeLaunch(String url){
               
               
               
                Log.d("aaa",url);
            }
               
            }



#############

now to call native method from javascript   just use this code in html file.( this html is loaded in webview)

html code

window.test_callback.nativeLaunch("paramater"); / this will call native method  in android....

Cheers :)


No comments:

FEEDJIT Live