Android Webview Response Reading - android

I am facing problem with reading response from the webview which loads a registration get url. The requirement is as below.
I have to communicate with a user registration servlet which can respond with html and xml content. For initial get request the servlet responds with html content and I can able to show that in WebView using load URL method. In the web view user enters the registration details and clicks submit, the servlet reponds with xml status code and registration details. I have to read this xml response from the servlet that can be obtained from the web view and do action (ex: close the web view and alert user) with respect to the xml response.
Please get me a solution.
I tried overriding Webview clients onPageFinsihed() and reading data again from the URL by opening an HTTP connection. I think this implementation communicates with the server two times, Is that correct?
Regards
#nish

You need to actually extract HTML from the WebView, this can be done in different ways this is one approach.

Related

How to read body of a POST request into Android WebView

I have to submit a form to an external URL, that provides into my WebView a series of interaction with the user.
At the end of this process this external service does a redirect to my another URL (that is fake) through a POST call, sending some data that I need to show at the user.
I tried to catch this POST request into the method shouldInterceptRequest, because I have to read data before the load of my fake url starts, but the methods that I can use on a WebResourceRequest object are useless. There is nothing to read the body of this request.
There is another way to catch my data? Any suggestions?
(I already tried the writeinterception project library, but it doesn't work.)
Thanks a lot in advance.

Receive POST information from callback, Android WebView

My scenario is this: we point the user to a form where they fill in the data (3DSecure) and then POST, the website then POSTS the response to a callback URL - this response is what I want to capture. WebView.shouldInterceptRequest() can get the headers but not the content (Why, Google?). I tried this link and it can get the POST data that the user sends. Is there any way to use Javascript to catch the POST data being received to a callback of my choosing?
I saw this post from 5 years ago and the man resorted to POSTing the response back to a server and then getting the contents from the phone. This is far from ideal. Surely there's a newer solution?
shouldInterceptRequest() mentions that a response contains the "response information or null if the WebView should load the resource itself", how do I get it so that the WebView shouldn't load the resource itself? The source code seems to return null always.
I used this gentleman's library: https://github.com/LivotovLabs/3DSView
If one was looking to do this with something other than 3DSecure they could use it as a template.

Getting callback from payment gateway in webview

I am using Atom Payment Gateway for payments in my Android app. But this provider doesn't have an SDK for mobile platforms, also I cannot choose another provider because my client has been using Atom PG for their website for a long time.
So to make it work, I am now trying to call it in a webview in my app. All goes well until the last step except that I am not able to get the response from the PG upon completion of transaction.
As per their documentation:
After the completion of the transaction, the response will be posted back to the url provided by the merchant.
I already tried setting the return url to my reverse domain name and then setting an intent-filter but that doesn't seem to work.
Is there any method by which I can get the response that the PG "posts back" to the return url?
Here is an idea,
On getting the post request on your return url, you can parse that response and then via javascript send that to the JavascriptInterface linked to your WebView in the app
Intercepting POST data has been discussed:
How to intercept POST data in an android webview
Intercept POST requests in a WebView
Try this project : https://github.com/KeejOow/android-post-webview

Android get request and response objects from webview

is there a way to get request and response objects from a webview?
for requests made from some webpage running in my webview, i want to intercept the full http request object(the headers, http method used, http body etc) and divert and send across that request into another channel.
For responses received from the webview, i want to do the same and get the object and its properties.
So far i have looked at the webviewClient android class which allows you to intercept url links executed by a webpage and intercept the resources it loads.
However, what i want to intercept, is any actual http requests the webpage makes. is this possible in Android webview?
thanks
That is not directly possible. You are welcome to write an HTTP proxy, then attempt to get WebView to work with that (e.g., see if it supports the http.proxyHost and http.proxyPort system properties).

How can I get post back response using webview in android?

Currently I am working on payment integration for native android app after send the request it have given me post back url with some attributes as success/fail response. I can't understand that how can I get those post back url attributes values using WebView . If any one know,
Please suggest me some idea for that.

Categories

Resources