0

I want to write a form proxy in my app. The html file is stored locally and the form code is

<form action="custom" method="POST" />

My custom WebView should handle the action tag differently. So custom should be redirected to a different URL, depending on user settings in my app.

I wrote a custom WebView and where I override postUrl, but it is never fired. I also tried a custom WebViewClient and override shouldOverrideUrlLoading, but this is also not fired.

Which method should I override to change my post url and the CONTENT-TYPE for my formular?

Edit: I found https://code.google.com/p/android/issues/detail?id=9122 and I thing nobody found a solution for this problem. That's really bad.

mars3142
  • 2,501
  • 4
  • 28
  • 58

1 Answers1

0

Inject javascript into WebView right after the page is loaded and change action of the form using it. You can simply inject javascript by calling webView.loadUrl("javascript:...");

Václav Hodek
  • 638
  • 4
  • 9
  • I didn't want to `WebView` to send the form data. My app should send the data, because I want to handle error messages etc. in it. – mars3142 Jul 01 '14 at 09:36
  • 1
    In that case use similar technique, inject javascript, but do not change action attribute and add onsubmit with function from your own JavascriptInterface to the form instead. Via JavascriptInterface, you can catch submitting of the form and act accordingly. – Václav Hodek Jul 01 '14 at 10:24
  • This could be a possible way. I'll check it out. – mars3142 Jul 01 '14 at 11:10