Status Update
Comments
cc...@gmail.com <cc...@gmail.com> #2
I proposed this which I think it is better than the actual behavior, and could let the developers work with more room to be creative.
https://code.google.com/p/android/issues/detail?id=58318
br...@gmail.com <br...@gmail.com> #3
The presentation link doesn't work.
ab...@gmail.com <ab...@gmail.com> #4
In Custom Notification Layouts section of the Notification API Guides, it states: "The height available for a custom notification layout depends on the notification view. Normal view layouts are limited to 64 dp, and expanded view layouts are limited to 256 dp". I guess it means the width is 512 dp and the height is 256 dp (if following the 2:1 aspect ratio)?
http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomNotification
pr...@gmail.com <pr...@gmail.com> #7
Any update on this?
st...@gmail.com <st...@gmail.com> #8
Thank you for your feedback. We assure you that we are doing our best to address all issues reported. For now, we will be closing the issue as won't fix obsolete. If this issue currently still exists, we request that you log a new issue along with the bug report here https://goo.gl/TbMiIO and reference this bug for context.
ab...@gmail.com <ab...@gmail.com> #9
Does anyone have a workaround for this in the meanwhile? In my opinion switching from GET to POST isn't really a solution fundamentally. Overriding postUrl doesn't seem to work for forms submitted by the user clicking a submit button.
ab...@gmail.com <ab...@gmail.com> #10
This is broken on both the 2.2 and 2.3 emulator, HTC Legend (2.1-update1), and Galaxy S (2.1-update1). The callback works properly in Nexus S (2.3), a OG Droid running CM7 (2.3), and a G2 (2.2).
zh...@gmail.com <zh...@gmail.com> #11
I am also looking for a workaround,but found nothing,and I think google will not solved this problem.
I make some test and found the way above of "@Override loadUrl&postUrl" does not work.
I make some test and found the way above of "@Override loadUrl&postUrl" does not work.
ni...@gmail.com <ni...@gmail.com> #12
I am having the same problem...do we have any solution ????
jo...@gmail.com <jo...@gmail.com> #13
Maybe you can solve it through override WebViewClient's onPageStarted() method, look like this:
class MyWebViewClient extends WebViewClient {
/**
* it will always be call.
*/
public void onPageStarted(WebView view, String url, Bitmap favicon){
if(IsIgnoreWebsite(url)){
view.stopLoading();
// @TODO ...
return;
}
}
}
If there has any other way, please tell me.
class MyWebViewClient extends WebViewClient {
/**
* it will always be call.
*/
public void onPageStarted(WebView view, String url, Bitmap favicon){
if(IsIgnoreWebsite(url)){
view.stopLoading();
// @TODO ...
return;
}
}
}
If there has any other way, please tell me.
mi...@gmail.com <mi...@gmail.com> #14
This issue still persist..has anybody got any solution? If yes, please share.
th...@gmail.com <th...@gmail.com> #15
I haven't actually tried this, but you can create a JavaScript interface, attach it to your webview instance, and call your Web page via a method in the js interface. Try calling this method from within the overridden postURL Webview method (see comment 3). The JavaScript function that is being called can be coded to suppress the Web page's form submit event's default action which will keep your Web page from refreshing.
fa...@gmail.com <fa...@gmail.com> #16
Is someone found a solution or a workaround to this problem ?
In my case I use the WebViewClient to filter the requests and use a custom SocketFactory (by overriding the "shouldInterceptRequest" method). It works fine with the GET requests but I can't intercept the POST requests. I read the source code of Android but I didn't found a correct way to bypass this problem.
In my case I use the WebViewClient to filter the requests and use a custom SocketFactory (by overriding the "shouldInterceptRequest" method). It works fine with the GET requests but I can't intercept the POST requests. I read the source code of Android but I didn't found a correct way to bypass this problem.
jr...@android.com <jr...@android.com>
ar...@gmail.com <ar...@gmail.com> #17
May I know if Android team is planning to fix this bug? In case, there is no plan to fix this, please share alternatives to intercept HTTP requests of type POST made by WebView.
no...@gmail.com <no...@gmail.com> #18
Anyone has got solution for this?
I also need to know how to intercept POST request in webView.
I also need to know how to intercept POST request in webView.
kr...@gmail.com <kr...@gmail.com> #19
I 'solved' it by letting Javascript intercept form submits and AJAX requests.
In shouldInterceptRequest, you add a Javascript snippet to the WebResourceResponse that you return:
if (mInterceptHeader == null) {
try {
mInterceptHeader = StringUtils.readInputStream(mContext.getAssets().open(
"www/interceptheader.html"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// Prefix every script to capture submits
// Make sure our interception is the first element in the
// header
org.jsoup.select.Elements el = doc.getElementsByTag("head");
if (el.size() > 0) {
el.get(0).prepend(mInterceptHeader);
}
where assets/interceptheader.html contains the following data
<script language="JavaScript">
HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit;
HTMLFormElement.prototype.submit = interceptor;
window.addEventListener('submit', function(e) {
interceptor(e);
}, true);
function interceptor(e) {
var frm = e ? e.target : this;
interceptor_onsubmit(frm);
frm._submit();
}
function interceptor_onsubmit(f) {
var jsonArr = [];
for (i = 0; i < f.elements.length; i++) {
var parName = f.elements[i].name;
var parValue = f.elements[i].value;
var parType = f.elements[i].type;
jsonArr.push({
name : parName,
value : parValue,
type : parType
});
}
interception.customSubmit(JSON.stringify(jsonArr),
f.attributes['method'] === undefined ? null
: f.attributes['method'].nodeValue,
f.attributes['enctype'] === undefined ? null
: f.attributes['enctype'].nodeValue);
}
lastXmlhttpRequestPrototypeMethod = null;
XMLHttpRequest.prototype.reallyOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
lastXmlhttpRequestPrototypeMethod = method;
this.reallyOpen(method, url, async, user, password);
};
XMLHttpRequest.prototype.reallySend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
interception.customAjax(lastXmlhttpRequestPrototypeMethod, body);
lastXmlhttpRequestPrototypeMethod = null;
this.reallySend(body);
};
</script>
This javascript calls the methods customSubmit or customAjax of the object 'interception' that has been added to the WebView if the next request will be a post form submit or a post ajax request. You add the javascript interface as follows
mWebView.addJavascriptInterface(new JavascriptPostIntercept(), "interception")
Assuming the existence of the JavascriptPostIntercept class with at least the following method snippets
public void customAjax(final String method, final String body) {
Log.i(TAG, "Submit data: " + method + " " + body);
mWebView.getWebViewClient().nextMessageIsAjaxRequest(new AjaxRequestContents(method, body));
}
public void customSubmit(String json, String method, String enctype) {
Log.i(TAG, "Submit data: " + json + "\t" + method + "\t" + enctype);
mWebView.getWebViewClient().nextMessageIsFormRequest(
new FormRequestContents(method, json, enctype));
}
What this code actually does is to say to your subclass of the WebViewClient, which contains the shouldInterceptRequest method, that the next call to shouldInterceptRequest will be a post request with the given parameters (encoded in JSON). In the overridden shouldInterceptRequest, you check whether a form request or AJAX request has been set and construct a POST request; if not you create a GET request.
This has allowed me to load rather complex web pages such as Outlook Web Access, Facebook, and so on in a custom browser. Let me know if you need more information or whether the general workflow is clear. Any suggestions are very valuable. If you want more elaborate source files, let me know and I'll have a look at distilling a basic sample from our application.
In shouldInterceptRequest, you add a Javascript snippet to the WebResourceResponse that you return:
if (mInterceptHeader == null) {
try {
mInterceptHeader = StringUtils.readInputStream(mContext.getAssets().open(
"www/interceptheader.html"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// Prefix every script to capture submits
// Make sure our interception is the first element in the
// header
org.jsoup.select.Elements el = doc.getElementsByTag("head");
if (el.size() > 0) {
el.get(0).prepend(mInterceptHeader);
}
where assets/interceptheader.html contains the following data
<script language="JavaScript">
HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit;
HTMLFormElement.prototype.submit = interceptor;
window.addEventListener('submit', function(e) {
interceptor(e);
}, true);
function interceptor(e) {
var frm = e ? e.target : this;
interceptor_onsubmit(frm);
frm._submit();
}
function interceptor_onsubmit(f) {
var jsonArr = [];
for (i = 0; i < f.elements.length; i++) {
var parName = f.elements[i].name;
var parValue = f.elements[i].value;
var parType = f.elements[i].type;
jsonArr.push({
name : parName,
value : parValue,
type : parType
});
}
interception.customSubmit(JSON.stringify(jsonArr),
f.attributes['method'] === undefined ? null
: f.attributes['method'].nodeValue,
f.attributes['enctype'] === undefined ? null
: f.attributes['enctype'].nodeValue);
}
lastXmlhttpRequestPrototypeMethod = null;
XMLHttpRequest.prototype.reallyOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
lastXmlhttpRequestPrototypeMethod = method;
this.reallyOpen(method, url, async, user, password);
};
XMLHttpRequest.prototype.reallySend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
interception.customAjax(lastXmlhttpRequestPrototypeMethod, body);
lastXmlhttpRequestPrototypeMethod = null;
this.reallySend(body);
};
</script>
This javascript calls the methods customSubmit or customAjax of the object 'interception' that has been added to the WebView if the next request will be a post form submit or a post ajax request. You add the javascript interface as follows
mWebView.addJavascriptInterface(new JavascriptPostIntercept(), "interception")
Assuming the existence of the JavascriptPostIntercept class with at least the following method snippets
public void customAjax(final String method, final String body) {
Log.i(TAG, "Submit data: " + method + " " + body);
mWebView.getWebViewClient().nextMessageIsAjaxRequest(new AjaxRequestContents(method, body));
}
public void customSubmit(String json, String method, String enctype) {
Log.i(TAG, "Submit data: " + json + "\t" + method + "\t" + enctype);
mWebView.getWebViewClient().nextMessageIsFormRequest(
new FormRequestContents(method, json, enctype));
}
What this code actually does is to say to your subclass of the WebViewClient, which contains the shouldInterceptRequest method, that the next call to shouldInterceptRequest will be a post request with the given parameters (encoded in JSON). In the overridden shouldInterceptRequest, you check whether a form request or AJAX request has been set and construct a POST request; if not you create a GET request.
This has allowed me to load rather complex web pages such as Outlook Web Access, Facebook, and so on in a custom browser. Let me know if you need more information or whether the general workflow is clear. Any suggestions are very valuable. If you want more elaborate source files, let me know and I'll have a look at distilling a basic sample from our application.
an...@gmail.com <an...@gmail.com> #20
an...@gmail.com <an...@gmail.com> #21
Hello,
I'm interested in comment #21 . I have understood all, but I would like the code of functions nextMessageIsAjaxRequest and nextMessageIsFormRequest and AjaxRequestContents and FormRequestContents classes. But would appreciate any examples.
Thanks.
I'm interested in
Thanks.
bg...@gmail.com <bg...@gmail.com> #22
an...@gmail.com <an...@gmail.com> #23
I am looking the solution suggested by kristof.Can u share the inner details about getWebviewClient,nextMessageIs Formrequest,and Form RequestContents.
kr...@gmail.com <kr...@gmail.com> #24
Hi everyone,
Sorry for my late answer. You can find a very simple sample application onhttps://github.com/KeejOow/android-post-webview/ . I hope it helps. Constructive suggestions are always welcome, as long as they improve the prototype in terms of clarity, simplicity or correctness. I know it's not a full-fletched browser, but let's assume that's out of the scope.
Cheers,
Kristof.
Sorry for my late answer. You can find a very simple sample application on
Cheers,
Kristof.
an...@gmail.com <an...@gmail.com> #25
@kristof
Thanks work for me.But how implement this to below android version 3.0?
Thanks work for me.But how implement this to below android version 3.0?
lu...@gmail.com <lu...@gmail.com> #26
Hi everyone,
It seems that this problem is solved in the newest API 21.
There, following new method is available:
API 21:
public WebResourceResponse shouldInterceptRequest (WebView view, WebResourceRequest request)
In the WebResourceRequest parameter the Information which HTTP-Method (POST,GET,DELETE,...) invoked the Interceptor is accessible.
But, I really would appreciate, if google would provide a compatibility- or support-library for older API's to use this functionality.
This functionality is essential for business-Applications.
E.g. Local rewriting all requests(POST,GET,DELETE,....) from a WebView with url's from an Intranet, which url's have to be rewritten (e.g. with Proxyname,)
@Google:
Please support us with fixes, workarounds for making this possible.
in Versions earlier than API, 21 only HTTP-Get Methods can be intercepted.
Thanks for supporting us
Lukas
It seems that this problem is solved in the newest API 21.
There, following new method is available:
API 21:
public WebResourceResponse shouldInterceptRequest (WebView view, WebResourceRequest request)
In the WebResourceRequest parameter the Information which HTTP-Method (POST,GET,DELETE,...) invoked the Interceptor is accessible.
But, I really would appreciate, if google would provide a compatibility- or support-library for older API's to use this functionality.
This functionality is essential for business-Applications.
E.g. Local rewriting all requests(POST,GET,DELETE,....) from a WebView with url's from an Intranet, which url's have to be rewritten (e.g. with Proxyname,)
@Google:
Please support us with fixes, workarounds for making this possible.
in Versions earlier than API, 21 only HTTP-Get Methods can be intercepted.
Thanks for supporting us
Lukas
[Deleted User] <[Deleted User]> #27
I tried to use:
public WebResourceResponse shouldInterceptRequest (WebView view, WebResourceRequest request)
Only to find out that getData() doesn't exist on WebResourceRequest, only on WebResourceResponse.
So I'm still forced to use the c21 workaround.
public WebResourceResponse shouldInterceptRequest (WebView view, WebResourceRequest request)
Only to find out that getData() doesn't exist on WebResourceRequest, only on WebResourceResponse.
So I'm still forced to use the c21 workaround.
el...@gmail.com <el...@gmail.com> #28
UGLY WORK!
UGLY ANDROID!
A LOT OF LOST TIME!
UGLY ANDROID!
A LOT OF LOST TIME!
ch...@gmail.com <ch...@gmail.com> #29
One of the hacky way (but working one for both get and post) is as follow:
My requirement was to intercept every xmlhttprequest going through my webapp (through webview). wrap that request with payload = {current url, current data} and send it to new url if webapp is deployed on mobile with some additional authentication fields. Otherwise from normal web browser it should straight away go to original service URL.
In normal flow how it works is, whenever xmlhttprequest is sent from webview (I used angular in my webview, so $http.post/get ), first it is initialized (readyState =0), goes inside prototype.open() method, then it goes inside prototype.send() method and then it is intercepted in shouldIntercept() method of android.
So I override XMLHttpRequest prototype open, setRequestHeader and send methods. From open method, i go methodType(GET/PUT/POST etc.), URL and in send method I got the payload. Then in overriden send method, I modified the request to wrap all these things into a new payload, encode that payload and append that payload and pass it in shouldInterceptRequest.
I have copied the part which I can post:
---------------------------------------------------------------------------
function(window, undefined) {
function overrideRequest(xhr) {
// Save the original send function
var origSendFunc = xhr.send;
// Save the original open function
var origOpenFunc = xhr.open;
// Save the original requestHeader function
var origSetRequestHeaderFunc = xhr.setRequestHeader;
// And the original abort function
var origAbortFunc = xhr.abort;
// override the open(), setRequestHeaders(), and send() methods in the prototype.
xhr.open = function(method, url, async, user, pass) {
this.originalArgs = arguments;
// Call the original open here to put the xhr in the opened state
// Need this to mimic a real xhr since some methods/properties can only be set
// if it is in opened state.
origOpenFunc.apply(this, arguments);
};
xhr.setRequestHeader = function(header, value) {
if (!this.headerArgs) {
this.headerArgs = {};
}
this.headerArgs[header] = value;
};
/** Provide the new send function.
* -Open request to the destination url.
* -Make the original request as intended.
*/
xhr.send = function(data) {
var xhrInstance = this;
var args = this.originalArgs;
var headers = this.headerArgs || {};
var url = args[1];
var methodType = args[0];
/*
ToDo: If request need to sent to new service through android then
1. Change the data to wrap an original URL as well as payload
New structure of data would be.
newData = {
operationURL: oldURL
operationMethod: GET/POST/PUT
operationData: oldData (coming in argument)
}
2. Encode this new data and append encoded newData it to newURL.
3. Make a send request to this newURL. so that data will be received
in android app.
*/
var newURL = url;
var newData = {};
if (shouldSendToNewService) {
newURL = '/api/someNewService?newdata=';
newData.U = url;
newData.D = data;
newData.M = methodType;
var payload = JSON.stringify(newData);
newURL = newURL + payload;
newURL = btoa(newURL); //Base64 encoding
}
this.abortCalled = false; // If it's true at this point, then that means ,
// abort was called before send() so we're going to ignore it.
var makeCall = function(requestUrl) {
args[1] = requestUrl;
// Call the original open, with the originally provided args (+ modified url)
origOpenFunc.apply(xhrInstance, args);
// Set any request headers we received
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
origSetRequestHeaderFunc.call(xhrInstance, header, headers[header]);
}
}
// Call original send to make the request.
origSendFunc.call(xhrInstance, data);
if (xhrInstance.abortCalled) {
origAbortFunc.call(xhrInstance);
}
};
makeCall(newURL);
};
//override abort method as well
xhr.abort = function() {
this.abortCalled = true;
origAbortFunc.call(this);
};
}
overrideRequest(XMLHttpRequest.prototype);
}(window);
---------------------------------------------------------------------------
Run above script to your html to be shown in webview. In android shouldInterceptUrl(webview, url), you get encoded url which contains all the data. In android webview then I can do decode the URL to get newData, do some necessary wrapping and posting to service and returning data by formatting in WebResourceResponse object.
One advantage is, you will not have to change anything in html, JS, css code if you are going to deploy it to normal webserver and if you are going to deploy it in mobile app as web app.
Please correct me if I have misunderstood anything here.
My requirement was to intercept every xmlhttprequest going through my webapp (through webview). wrap that request with payload = {current url, current data} and send it to new url if webapp is deployed on mobile with some additional authentication fields. Otherwise from normal web browser it should straight away go to original service URL.
In normal flow how it works is, whenever xmlhttprequest is sent from webview (I used angular in my webview, so $
So I override XMLHttpRequest prototype open, setRequestHeader and send methods. From open method, i go methodType(GET/PUT/POST etc.), URL and in send method I got the payload. Then in overriden send method, I modified the request to wrap all these things into a new payload, encode that payload and append that payload and pass it in shouldInterceptRequest.
I have copied the part which I can post:
---------------------------------------------------------------------------
function(window, undefined) {
function overrideRequest(xhr) {
// Save the original send function
var origSendFunc = xhr.send;
// Save the original open function
var origOpenFunc = xhr.open;
// Save the original requestHeader function
var origSetRequestHeaderFunc = xhr.setRequestHeader;
// And the original abort function
var origAbortFunc = xhr.abort;
// override the open(), setRequestHeaders(), and send() methods in the prototype.
xhr.open = function(method, url, async, user, pass) {
this.originalArgs = arguments;
// Call the original open here to put the xhr in the opened state
// Need this to mimic a real xhr since some methods/properties can only be set
// if it is in opened state.
origOpenFunc.apply(this, arguments);
};
xhr.setRequestHeader = function(header, value) {
if (!this.headerArgs) {
this.headerArgs = {};
}
this.headerArgs[header] = value;
};
/** Provide the new send function.
* -Open request to the destination url.
* -Make the original request as intended.
*/
xhr.send = function(data) {
var xhrInstance = this;
var args = this.originalArgs;
var headers = this.headerArgs || {};
var url = args[1];
var methodType = args[0];
/*
ToDo: If request need to sent to new service through android then
1. Change the data to wrap an original URL as well as payload
New structure of data would be.
newData = {
operationURL: oldURL
operationMethod: GET/POST/PUT
operationData: oldData (coming in argument)
}
2. Encode this new data and append encoded newData it to newURL.
3. Make a send request to this newURL. so that data will be received
in android app.
*/
var newURL = url;
var newData = {};
if (shouldSendToNewService) {
newURL = '/api/someNewService?newdata=';
newData.U = url;
newData.D = data;
newData.M = methodType;
var payload = JSON.stringify(newData);
newURL = newURL + payload;
newURL = btoa(newURL); //Base64 encoding
}
this.abortCalled = false; // If it's true at this point, then that means ,
// abort was called before send() so we're going to ignore it.
var makeCall = function(requestUrl) {
args[1] = requestUrl;
// Call the original open, with the originally provided args (+ modified url)
origOpenFunc.apply(xhrInstance, args);
// Set any request headers we received
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
origSetRequestHeaderFunc.call(xhrInstance, header, headers[header]);
}
}
// Call original send to make the request.
origSendFunc.call(xhrInstance, data);
if (xhrInstance.abortCalled) {
origAbortFunc.call(xhrInstance);
}
};
makeCall(newURL);
};
//override abort method as well
xhr.abort = function() {
this.abortCalled = true;
origAbortFunc.call(this);
};
}
overrideRequest(XMLHttpRequest.prototype);
}(window);
---------------------------------------------------------------------------
Run above script to your html to be shown in webview. In android shouldInterceptUrl(webview, url), you get encoded url which contains all the data. In android webview then I can do decode the URL to get newData, do some necessary wrapping and posting to service and returning data by formatting in WebResourceResponse object.
One advantage is, you will not have to change anything in html, JS, css code if you are going to deploy it to normal webserver and if you are going to deploy it in mobile app as web app.
Please correct me if I have misunderstood anything here.
ch...@gmail.com <ch...@gmail.com> #30
[Comment deleted]
ch...@gmail.com <ch...@gmail.com> #31
Some of the caveats of my solution in comment#31 I see are:
1. URL length issue for some of the browsers if you big data to post
2. Putting a dependency on xmlhttprequest prototype which has different implementation for different webkits.
3. Security issue in sending data for post requests in URL. But I guess you can solve that through some encryption mechanism.
But I think android should provide some mechanism to get all the parameters like url, method type, data inside shouldInterceptRequest method. API 21 includes shouldInterceptRequest(view, webResourceRequest) but webresourceRequest does not provide data. So you can not modify the data.
1. URL length issue for some of the browsers if you big data to post
2. Putting a dependency on xmlhttprequest prototype which has different implementation for different webkits.
3. Security issue in sending data for post requests in URL. But I guess you can solve that through some encryption mechanism.
But I think android should provide some mechanism to get all the parameters like url, method type, data inside shouldInterceptRequest method. API 21 includes shouldInterceptRequest(view, webResourceRequest) but webresourceRequest does not provide data. So you can not modify the data.
[Deleted User] <[Deleted User]> #32
still experiencing the same issue with android lolipop version
sa...@gmail.com <sa...@gmail.com> #33
I want to intercept all HTTP Connect request within the Webview. How can i do so?
pl...@gmail.com <pl...@gmail.com> #35
I tried the solution given in #21 but at least on android 7 or the web site I tried, it doesn't work at all, when I press submit button with the hijacked page, nothing happens :( It's really a shame that this bug is still here after 7 years
[Deleted User] <[Deleted User]> #36
+1
th...@gmail.com <th...@gmail.com> #37
+1
ek...@gmail.com <ek...@gmail.com> #38
+1
ho...@gmail.com <ho...@gmail.com> #39
+1
yu...@gmail.com <yu...@gmail.com> #40
++++++1111111
sc...@gmail.com <sc...@gmail.com> #41
+1
sc...@gmail.com <sc...@gmail.com> #42
I wrote a library that proves an extended WebViewClient with a special `shouldOverrideUrlLoading` method that allows you to access the POST/PUT/ ... data.
https://github.com/KonstantinSchubert/request_data_webviewclient
In the current state, the library only works for XMLHTTPRequests, but the extension to form submits is likely possible.
I have used it successfully in a project where I had to proxy all requests by a third party Single Page Application.
In the current state, the library only works for XMLHTTPRequests, but the extension to form submits is likely possible.
I have used it successfully in a project where I had to proxy all requests by a third party Single Page Application.
pe...@gmail.com <pe...@gmail.com> #43
+1
ar...@gmail.com <ar...@gmail.com> #44
+1
ju...@gmail.com <ju...@gmail.com> #45
+1
[Deleted User] <[Deleted User]> #46
+1
[Deleted User] <[Deleted User]> #47
+1
iq...@gmail.com <iq...@gmail.com> #48
I have this scenario
1 - Remote server returns HTML ready to display in WebView (without javascript)
2 - This html is having FORM with method=post
2.1 - Take input from user in a form field ()
3 - I need to capture whole form data after user click
4 - I have to send the form data to a remote server for a verification.
This is HTML:
<form action="HTTPS://URL " method="post" name="cardholderInput">
<input type="text" class="input-field" name="code" value=" Enter Code Here">
<input type="submit" class="button primary" value="SUBMIT">
</form>
<form action="HTTPS://URL " method="post" name="resendChallengeData">
<input type="hidden" name="resend" value="true">
<input type="submit" class="button" value="RESEND CODE">
</form>
I can not change HTML , not to use javascript (requirement).
This is very strange that Android doesn't give any way to have this. I have tried followings but no luck:
public boolean shouldOverrideUrlLoading(WebView view, String url) // WORKS good for GET method
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) //it is called when user click on BUTTON but form data with user value is missing)
Any suggestion or Idea?
Thanks
Regards
Asif Iqbal
1 - Remote server returns HTML ready to display in WebView (without javascript)
2 - This html is having FORM with method=post
2.1 - Take input from user in a form field ()
3 - I need to capture whole form data after user click
4 - I have to send the form data to a remote server for a verification.
This is HTML:
<form action="
<input type="text" class="input-field" name="code" value=" Enter Code Here">
<input type="submit" class="button primary" value="SUBMIT">
</form>
<form action="
<input type="hidden" name="resend" value="true">
<input type="submit" class="button" value="RESEND CODE">
</form>
I can not change HTML , not to use javascript (requirement).
This is very strange that Android doesn't give any way to have this. I have tried followings but no luck:
public boolean shouldOverrideUrlLoading(WebView view, String url) // WORKS good for GET method
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) //it is called when user click on BUTTON but form data with user value is missing)
Any suggestion or Idea?
Thanks
Regards
Asif Iqbal
nt...@google.com <nt...@google.com>
ti...@google.com <ti...@google.com> #49
yes looks like this is be a limitation of the current API, potentially something to consider..
to...@google.com <to...@google.com> #50
We're planning to implement a new more powerful network request interception API in a future version, which will be available to L+ devices with a recent enough WebView via AndroidX. Being able to read POST bodies is one of the features we're intending to include. Unfortunately we can't share schedule information about when this may be available, but we are aware of this use case and intend to support it.
ka...@gmail.com <ka...@gmail.com> #51
I'm facing similar problem like this. Tried using shouldInterceptRequest in my webview, I can able to detect my POST/PUT request, but I'm unable to get my request body there. Is, it possible to read my POST request body ?
to...@google.com <to...@google.com> #52
No - as the replies on this bug and the bugs it has been duped into have stated, there is no way to do this at present. We are looking at adding a new API for this purpose in future but it's not expected to be available soon (the work was delayed due to schedule conflicts with other critical network stack changes).
ka...@gmail.com <ka...@gmail.com> #53
So, you are saying that it is impossible to read my POST request body in WebView. I'm I correct.
to...@google.com <to...@google.com> #54
Yes. It's currently impossible to read request bodies in WebView.
mi...@gmail.com <mi...@gmail.com> #55
Has there been any new traction on this topic?
rs...@gmail.com <rs...@gmail.com> #56
Adding comment at request of Google. We have identified 47 customers including very large, global industry leaders and 6 partners impacted.
na...@gmail.com <na...@gmail.com> #57
Any update on this issue?
to...@gmail.com <to...@gmail.com> #58
Hello please fix this issue
su...@amazon.com <su...@amazon.com> #59
Waiting for a fix
ze...@hotmail.com <ze...@hotmail.com> #60
+1
ne...@gmail.com <ne...@gmail.com> #61
bump
vs...@gmail.com <vs...@gmail.com> #62
waiting for a fix as well.
ts...@thinkdesquared.com <ts...@thinkdesquared.com> #63
12 years after, we are waiting for a fix.
as...@gmail.com <as...@gmail.com> #64
Hi Any update here? This is a basic webView function in iOS, a little sad that its this complicated in Android
ol...@gmail.com <ol...@gmail.com> #65
Comment has been deleted.
ol...@gmail.com <ol...@gmail.com> #66
13 years and waiting for a fix...
ab...@kobil.com <ab...@kobil.com> #67
yes still waiting ...
pr...@gmail.com <pr...@gmail.com> #68
Hi Team, any update or any workaround regarding this issue
ew...@gmail.com <ew...@gmail.com> #69
I think this is getting fixed a bit too quickly!
mi...@gmail.com <mi...@gmail.com> #70
LOL! You made my day.
ja...@lhind.dlh.de <ja...@lhind.dlh.de> #71
Officially waiting 14 years now....
Description
overloading the shouldOverrideUrlLoading, it works fine for links
<a href="apa"> and for form posts that uses GET method. But when I change
the post method to POST its not notified by the
shouldOverrideUrlLoading method.
With kind regards
Andreas
package test.apa;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class test extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create view
WebView webView = new WebView(this);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
System.out.println("shouldOverrideUrlLoading...");
return true;
}
});
String browserText = "<html><body><form method=\"post\"> <input type=\"submit\" value=\"Post Click!\"></form><form method=\"get\"> <input type=\"submit\" value=\"Get Click!\"></form> <a href=\"index.html\">Link Click</a></body></html>";
webView.loadData(browserText,"text/html","utf8");
setContentView(webView);
}
}