Local android service receive data from local web page

巧了我就是萌 提交于 2019-12-06 16:29:10
Knickedi

You should be carful when using the word Service besides android. People might get a worng idea of what you're taliking about because it has a special meaning for android.

Because a local webpage will submit a post request to a certain URL and your device is actually not the webserver you will fail with that. But you can accomplish your task with a javascript/JSON bridge to your local HTML. See this post to see how.

The idea is to use a click handler which collects the needed data and returns it to the webview by the javascript bridge instead submiting the data to a from submit URL. From java side to WebView you can respond with an JSON object.

To accomplish this you need to have fundamental knowledge about HTML and javascript and understand the use of a WebView.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!