Execute javascript without webview in Android -


i'm trying execute js fonction in android app. function in .js file on website.

i'm not using webview, want execute js function because sends request want.

in console in browser have question.vote(0);, how can in app ?

you can execute javascript without webview. can use androidjscore. here quick example how might it:

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);"); 

however, won't work outside of webview, because presume not relying on javascript, ajax, not part of pure javascript. requires browser implementation.

is there reason don't use hidden webview , inject code?

// create webview , load page includes js file webview.evaluatejavascript("question.vote(0);", null);      

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -