Local android service receive data from local web page

可紊 提交于 2019-12-23 03:39:20

问题


I have offline web page on android tablet.

Is it possible to write android service which will get data from web page when user insert data and submit it, and when android service receive data than it has to save it in text file or db.

Everything is in offline local mode.


回答1:


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.



来源:https://stackoverflow.com/questions/7553455/local-android-service-receive-data-from-local-web-page

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