0

My android app is getting session id as part of login service response, for the subsequent requests i have to pass this sess id. Now I'm using jquerymobile pages as webview content. I have to call some services from jquerymobile page using ajax.

Can I pass sessid from android native code to jquerymobile for this.

Thanks in advance.

Thanks, Venkat Papana

Venkat Papana
  • 4,757
  • 13
  • 52
  • 74

2 Answers2

0

(It's quite the same question I answered here.)
So this answer describes how to communicate with your webview with a javascript bridge.

I think that's what your looking for...

Community
  • 1
  • 1
Knickedi
  • 8,742
  • 3
  • 43
  • 45
  • Thank you very much @Knickedi, but is it safe to pass sessid from JavaScriptInterface to jQM using a getter method? – Venkat Papana Sep 28 '11 at 16:28
  • Those pages are local, so on your device? Am I right? It wouldn't be save to communicate with a website you actually not host yourself because you would grant the website to call native code in your app. – Knickedi Sep 28 '11 at 16:36
0

If I understand well, you're using ajax, meaning the webview content is served by a remote site.

Assuming you have access to the site javascript, simply define a callback, say sessidFromAndroid(sessid) then get it called by java :

mWebview.loadUrl("javascript:sessidFromAndroid("+mSession+")");
Laurent'
  • 2,611
  • 1
  • 14
  • 22