सबसे पहले, मुझे यह कहना है कि मुझे विश्वास नहीं है कि वेबव्यू इतना बेकार है।
यह मैं क्या कस्टम हेडर
public class CustomWebview extends WebView {
public void loadWithHeaders(String url) {
setWebViewClient(new WebViewClient() {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
//makes a custom http request, which allows you to add your own headers
return customRequest(url);
}
});
loadUrl(url);
}
/**
* Custom http request with headers
* @param url
* @return
*/
private WebResourceResponse customRequest(String url) {
try {
OkHttpClient httpClient = new OkHttpClient();
Request request = new Request.Builder()
.url(url.trim())
.addHeader("Header-Name", "Android Sucks")
.build();
Response response = httpClient.newCall(request).execute();
return new WebResourceResponse(
"text/html", // You can set something other as default content-type
"utf-8", // Again, you can set another encoding as default
response.body().byteStream()
);
} catch (IOException e) {
//return null to tell WebView we failed to fetch it WebView should try again.
return null;
}
}
}
+1 @stotherd आप इस समस्या को मैं इस के साथ भी अटक और कर रहा हूँ के लिए किसी भी समाधान मिला समाधान खोजने के लिए सक्षम नहीं था पारित करने के लिए किया था? –
दुर्भाग्य से नहीं, मुझे अलग-अलग संसाधनों का अलग-अलग अनुरोध करना पड़ा, और फिर परियोजना को पूरा नहीं किया। – stotherd