I'm trying to execute a js fonction in my Android app.
The function is in a .js file on a website.
I'm not using webview, i want to execute the js function because it sends the request i want.
In the Console in my browser i just have to do "question.vote(0);", how can i do it in my app ?
HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet("http://your_website_here/file.js"); HttpResponse response = client.execute(request); String js = EntityUtils.toString(response.getEntity()); JSContext context = new JSContext(); context.evaluateScript(js); context.evaluateScript("question.vote(0);");
Is there a reason you don't use a hidden WebView and simply inject your code?