How to intercept POST data in an android webview

后端 未结 6 1081
故里飘歌
故里飘歌 2020-12-08 14:34

I have an android app that consists of a webview. It needs to allow users to fill in a form on a webpage and then change the data of the form after the user has clicked

6条回答
  •  囚心锁ツ
    2020-12-08 14:49

    I liked the suggestion for public void postUrl(String url, byte[] postData) , but unfortunately it did not work for me.

    My solution for just intercepting the POST request:

    • have a WebViewClient subclass that is set for WebView
    • override public void onPageStarted(WebView view, String url, Bitmap favicon) to examine the request data and act accordingly (as per requirements)

    Code excerpt & additional thoughts here: https://stackoverflow.com/a/9493323/2162226

提交回复
热议问题