본문 바로가기

Android/WebView

[Android] WebView tip - Local Storage enable



안드로이드에서 센차등을 이용해서 웹앱을 개발할때 필요한 설정이 있습니다.
Local storage 사용에 대해서 허용을 해주어야 하는데요.
local storage를 허용해주지 않으면 아래와 같은 에러가 발생합니다.

11-07 17:33:35.023: E/Web Console(16537): Uncaught Local Storage is not supported in this browser, please use another type of data proxy at http://dev.sencha.com/deploy/touch/sencha-touch.js:6

11-07 17:33:35.031: E/Web Console(16537): Uncaught Error: The 'undefined' type has not been registered with this manager at http://dev.sencha.com/deploy/touch/sencha-touch.js:6

11-07 17:33:38.664: E/Web Console(16537): Uncaught TypeError: undefined is not a function at http://dev.sencha.com/deploy/touch/examples/oreilly/src/index.js:6 



추가할 설정은 DomStorageEnabled입니다.

WebView에서 setting을 가져옵니다. getSetting()
그리고 WebSetting인스턴스를 이용해서 setDomStorageEnabled(true)를 해줍니다.






 테스트 단말 : Nexus S / Galaxy S
 테스트 URL : http://dev.sencha.com/deploy/touch/examples/oreilly
 
 기타 WebSettings에 설정된 것들 중..
 - setJavaScriptEnabled(true);
 - setWebViewClient(new WebViewClient());
 - setWebChromeClient(new WebChromeClient()); 

setDomStorageEnabled(true) 을 설정하기전에는 페이지가 제대로 렌더링 되지 않다가, 설정을 추가한 후에는 제대로 렌더링이 되는것을 확인하실 수 있습니다.