Before starting use https my application it worked with http request. Everything is worked fine. But when I decided to change all url to https I have one unsolved problem. I can't show images in webview it doesn't show nothing. What should I do here to show images using https request.
Loading https url shows blank page because you should decide if your app wants to proceed to an untrusted web site via a WebView. You can set this by overriding onReceivedSslError method in WebViewClient. I tested your image and it shows proper image.
webView.setWebViewClient(new CustomWebViewClient());
...
private class CustomViewClient extends WebViewClient
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
}
However, this only works from Android 2.2(Froyo). For Android version below 2.2, a public API is not provided.
Related
I am currently testing the DocuSign API with the Demo Sandbox.
I have a WebAPI in C# which uses the DocuSign API. I create an enveloppe containing the document to sign and generate the recipient View URL.
I also have an Android App with a Webview which is supposed to get the generated URL to permit the user to sign the document.
When the webview loads the URL, the error ERR_CONNECTION_RESET occurs.
I precise that it works well using the Android Emulator but not with my phone connected in WI-FI.
Thanks in advance.
I copy/pasted the URL to my phone browser and it works. It's only within the App and the Webview that I can reach it.
I expect to reach the Docusign signing page related to my Document.
The WebView shows an ERR_CONNECTION_RESET
EDIT :
Here is some code
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest url) {
if((url.getUrl()).toString().equals(Constant.URL + "?event=signing_complete"))
{
/*Some code to redirect to other activity*/
return true;
}
else
{
Log.i("url",rep);
myWebView.loadUrl(rep);
return false;
}
}
#Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error){
//myWebView.loadUrl(rep);
Log.d("ERROR", error.getErrorCode());
}
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
Log.i("SSL", "SSL error");
handler.proceed();
}
});
[here is the result in the webview][1]
[1]: https://i.stack.imgur.com/yRuly.png
EDIT 2 :
If it can help, My .NET WEB API is hosted on my computer with Windows IIS and is connected to the network through Ethernet.
The Android device is connected via WI-FI to the same network.
I don't know if the error is because of the usage of SSL to access the signing page of Docusign.
I tried to replace the url of the webview by google.com and it worked fine.
It would be great if you added some code, so we can easily trace the error.
Have you tried adding
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
to your web view?
I finally solved my problem but still don't understand the reasons.
I manually uninstalled the application from the device.
I reinstalled it and it worked, just feels so stupid that I didn't try that at first...
"Have you tried turning it off and on again ?"
I have tested my app with many https URLs, almost all are working fine but not the one I want. I have tested my URL, it's working fine with all the browser except Internet Explorer.
Already handling SSL Error
Override shouldOverrideUrlLoading too.
webView.getSettings().setJavaScriptEnabled(true);
I want to know whether it's the problem in the URL or from Android.
I have solved my problem by enabling DomStorage.
webview.getSettings().setDomStorageEnabled(true);
I have searched about domStorage, as i understand it works if website using HTML5. Don't know too much about dom storage.
Just try to ignore SSL, check below snippet.
webView.setWebViewClient(webViewClient);
private WebViewClient webViewClient = new WebViewClient() {
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed(); // Ignore SSL certificate errors
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
};
Did you enable javascript on the webview?
webView.getSettings().setJavaScriptEnabled(true);
Most probably, its the problem in the URL not with the Android. As you are saying there is no SSL certificate issue and all other https URL's are working except yours.
You should contact your service provider or check from web end.
So from my first screen I am passing a URL to an activity to launch in webview. But when webview is launched , it shows "web page not available - The web page at URL might be temporarily down or it may have moved permanently to a new web address"
But when i launch the same URL in android browser, it works fine. Here is my code for launching that URL in webview
super.onCreate(savedInstanceState);
String url = "";
url = getIntent().getStringExtra("loginURL");
WebView urlWebView = new WebView(this);
urlWebView.setWebViewClient(new WebViewClient());
urlWebView.getSettings().setJavaScriptEnabled(true);
urlWebView.loadUrl(url);
this.setContentView(urlWebView);
What am I doing wrong?
I found the issue. The issue was that the URL I was using has https:// and SSL certificate for the URL was self-signed. The solution from Does the Web View on Android support SSL? helped me fixed the issue.
I added below part in my code
import android.net.http.*; //added this import statement
urlWebView.setWebViewClient(new WebViewClient(){
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error){
handler.proceed();
}
});
Hope this will help other users.
Make sure the url string you're loading has "www" prefixed to it, i.e. "https://www.google.com" and not "https://google.com"
Weirdly enough, this fixed the issue, at least on my end.
I have a WebView based application where I want to display a video which is inside a video tag like this:
<video src="https://video.mp4" controls="controls" type="video/mp4"></video>
I want to display the video inline (not fullscreen) and like the documentation says I have hardware acceleration turned on, and set a WebChromeClient.
The thing is when I replace the url from https to http it works and I can see the video correctly, but doesn't work with https.
Is https supported by the media player? Any thoughts on this? Thanks.
Have you tried setting a WebViewClient
myWebView.setWebViewClient(new WebViewClient() {
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
handler.proceed();
super.onReceivedSslError(view, handler, error);
}
I want to load a web page in my webView.
Tried placing the webView.loadurl("") in AsyncTask's doinbackground / onpostexecute
and in the onresume.
The url is correct but nothing happens it just shows a white page. In the android manifest file internet access is enabled.
What else needs to be done to load a webview?
The application does not crash or show any error.
In my emulator I set the proxy with my user name and password.
Here is the code I use to load the URL:
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClientSubClass());
webView.loadUrl(promoURL);
I would recommend you to check what callbacks your webViewClient is getting. I'm guessing that the site requests an authentication, so override onReceivedHttpAuthRequest and do something like this
#Override
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
Log.d(TAG, "onReceivedHttpAuthRequest"));
handler.proceed(username, password);
}
Or if the authentication isn't the problem you can always overide onReceivedSslError to see if there is some certificate problem.
As the initial step though, I would recommend you to use the browser to see if you can load the page. I'm having some trouble with an https site that requires authentication, I enter my credentials and the site can't load(this is on android 2.3)
myVideoView = (WebView) findViewById(R.id.webView1);
myVideoView.setWebViewClient(new WebViewClientSubClass());
myVideoView.getSettings().setJavaScriptEnabled(true);
myVideoView.setPersistentDrawingCache(0);
myVideoView.getSettings().setPluginsEnabled(true);
myVideoView.requestFocus(View.FOCUS_DOWN);
myVideoView.loadUrl(promoUrl);
try this should work and also check whether it opens with https in normal browser.