hi,
I'm using shouldInterceptRequest method to intercept the request , edit it
and send the right response.
It works on a couple phones I tested, but when I try to run the same code
on a different Android device - it crashes.
the code is looks like this:
@Override
public WebResourceResponse shouldInterceptRequest( WebView view, String url
)
{
if( (url.indexOf("Action=DoSomething")>-1 ) ){
String str = "Success";
WebResourceResponse response = new WebResourceResponse( "text/html",
"charset=UTF-8", new ByteArrayInputStream(
str.getBytes(StandardCharsets.UTF_8 )) );
HashMap<String, String> headersMap = new HashMap<String,String>();
headersMap.put( "Access-Control-Allow-Headers", "Content-Type" );
headersMap.put( "Access-Control-Allow-Methods", "GET,POST" );
headersMap.put( "Access-Control-Allow-Origin", "http:// <certain-url>"
);
headersMap.put( "Cache-Control", "private, max-age=0" );
response.setResponseHeaders( headersMap );
return response;
}
else{
return null;
}
}
I've found that without the the setResponseHeaders the app doesn't crash.
Otherwise it runs good on phones , but crashes on a certain Android device
that I want to run this code on.
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/f8b15d67-15b9-4bc9-9925-fc4dcf7d0551%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.