Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass data from webview back to the native Android app

Our Android app has a WebView which shows a page from our web-server. The page does a user registration (either via Facebook or by choosing a username and password). After that, I want the page to pass information back to the native app (e.g., username, license type, messges, etc.).

I know of JavaScript<->Java binding (addJavaScriptInterface), but was wondering is there a different way do to it:

like image 994
Menny Avatar asked Nov 14 '22 07:11

Menny


1 Answers

After the user logs in, you can capture data from the URL using WebView::getUrl(). Alternately, you could use cookies.

http://pragungoyal.com/tutorials/extracting-cookies-from-a-webview-in-android/

like image 101
saxman Avatar answered Nov 27 '22 10:11

saxman