티스토리 뷰

반응형

Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.

Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.

 

아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

Android webview launches browser when calling loadurl

loadurl을 호출할 때 Android 웹 뷰가 브라우저를 실행합니다.

 문제 내용 

I created an Activity that has a title and a web view in a LinearLayout. In the onResume() method it calls webView.loadUrl(url). The problem is that the activity first shows the title with the rest of the screen blank, then the device browser is launched with the page for the URL. What I want to see is the page being shown in the WebView below the title. What could be the problem?

LinearLayout에 제목과 웹 보기가 있는 액티비티를 만들었습니다. onResume() 메서드에서 webView.loadUrl(url)을 호출합니다. 문제는 액티비티가 먼저 화면의 나머지 부분이 비어 있는 상태에서 제목을 표시한 다음 URL 페이지와 함께 장치 브라우저가 실행된다는 것입니다. 내가 보고 싶은 것은 제목 아래의 웹 보기에 표시되는 페이지이다. 뭐가 문제일까요?

 

Edit: Ok, did some further search and found this one:

편집: 좋아요, 좀 더 검색해서 다음을 찾았습니다.

 

Clicking URLs opens default browser

URL을 클릭하면 기본 브라우저가 열립니다.

 

It points to the WebView tutorial here.

여기서 WebView tutorial을 가리킵니다.

 

Just implement the web client and set it.

웹 클라이언트를 구현하고 설정하기만 하면 됩니다.

 

 

 

 높은 점수를 받은 Solution 

Answering my question based on the suggestions from Maudicus and Hit.

마우디쿠스와 히트의 제안을 바탕으로 내 질문에 답한다.

 

Check the WebView tutorial here. Just implement the web client and set it before loadUrl. The simplest way is:

여기서 WebView tutorial를 확인하십시오. 웹 클라이언트를 구현하고 loadUrl 전에 설정하기만 하면 됩니다. 가장 간단한 방법은 다음과 같습니다.
myWebView.setWebViewClient(new WebViewClient());

 

For more advanced processing for the web content, consider the ChromeClient.

웹 콘텐츠에 대한 고급 처리를 위해 ChromeClient를 고려하십시오.

 

 

 

 가장 최근 달린 Solution 

If you see an empty page, enable JavaScript.

빈 페이지가 나타나면 JavaScript를 활성화하십시오.
webView.setWebViewClient(new WebViewClient());
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webView.loadUrl(url);

 

 

출처 : https://stackoverflow.com/questions/7746409/android-webview-launches-browser-when-calling-loadurl

반응형
댓글
공지사항
최근에 올라온 글