티스토리 뷰
Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.
Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.
아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.
Android WebView not loading an HTTPS URL
Android WebView가 HTTPS URL을 로드하지 않습니다.
문제 내용
public void onCreate(Bundle savedInstance)
{
super.onCreate(savedInstance);
setContentView(R.layout.show_voucher);
webView=(WebView)findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
String url ="https://www.paymeon.com/Vouchers/?v=%C80%8D%B1x%D9%CFqh%FA%84%C35%0A%1F%CE&iv=%25%EE%BEi%F4%DAT%E1"
//webView.loadUrl(url); // Not Working... Showing blank
webView.loadUrl("http://www.yahoo.com"); // its working
}
When I try to load a URL in the WebBView it only shows a blank screen. If I load Google.com or yahoo.com it's working fine.
WebBView에서 URL을 로드하려고하면 빈 화면만 나타납니다. 그러나 Google.com 또는 yahoo.com을 로드하면 정상적으로 작동합니다.
높은 점수를 받은 Solution
아래 링크를 방문해주세요:
Add this overriding method to your WebViewClient implementation. You'll need to compile it with Android SDK 2.2 (API level 8) or later. The method appears in the public SDK as of 2.2 (API level 8) but we've tested it on devices running 2.1, 1.6 and 1.5 and it works on those devices too (so obviously the behaviour has been there all along).
WebViewClient 구현에이 오버라이딩 메소드를 추가하십시오. Android SDK 2.2 (API 레벨 8) 이상으로 컴파일해야합니다. 이 메소드는 공개 SDK에 2.2 (API 레벨 8) 이상으로 표시되지만 2.1, 1.6 및 1.5에서 실행되는 장치에서도 작동되므로 (즉, 동작은 항상 있었습니다) 이전 버전에서도 사용할 수 있습니다.
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed(); // Ignore SSL certificate errors
}
this will help you.
이것이 도움이 될 것입니다.
가장 최근 달린 Solution
Copy and paste your code line bro , it will work trust me :) i am thinking ,you get a ssl error. İf you use override onReceivedSslError method and remove super it's super method. Just write handler.proceed() ,error will solve.
당신의 코드 라인을 복사하여 붙여 넣으세요. 그러면 작동할 것입니다. 나는 SSL 오류가 발생하는 것 같다고 생각합니다. 만약 onReceivedSslError 메소드를 오버라이드하여 super 메소드를 제거하고 handler.proceed()만 작성하면 오류가 해결될 것입니다.
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if (progress == 100)
activity.setTitle(getResources().getString(R.string.app_name));
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.d("Failure Url :" , failingUrl);
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
Log.d("Ssl Error:",handler.toString() + "error:" + error);
handler.proceed();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setDomStorageEnabled(true);
webView.loadUrl(Constant.VIRTUALPOS_URL + "token=" + Preference.getInstance(getContext()).getToken() + "&dealer=" + Preference.getInstance(getContext()).getDealerCode());
출처 : https://stackoverflow.com/questions/7416096/android-webview-not-loading-an-https-url
'개발 > 안드로이드' 카테고리의 다른 글
안드로이드 화면 녹화하기 (0) | 2023.02.06 |
---|---|
안드로이드에서 전역 변수 만드는 방법 (0) | 2023.02.06 |
startActivity() 동작 안할 때 확인해 볼 것들.. (0) | 2023.02.05 |
WebView 데이터 로드 후 스크롤뷰가 스크롤되는 문제 수정하기 (0) | 2023.02.05 |
EditText를 둥근 모서리로 만들기 (0) | 2023.02.05 |