Can I use polymer/web components in a native android app w/o Cordova?

ε祈祈猫儿з 提交于 2019-12-03 02:51:59

问题


If I'm not mistaken, you need a web server to use/test Polymer's web components (such as the paper elements) on your computer due to browser permissions issues stemming from loading local file://s.

(A simple solution is to navigate to the directory where the polymer files are you want to try and type python -m SimpleHTTPServer then load http://localhost:8000 and all is good.)

But how about if I want to employ web components/Polymer elements in a native java android app inside a simple WebView w/o dealing with Cordova or setting up a web server somehow inside my app. Will I be able to do it easily, or will I have the same permissions issues?

Thanks in advance.


回答1:


Yes! I'm hoping to write an article on this in the next few weeks. For the imports to load from file://, I've been successful with the following settings:

WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true); // Enable Javascript.
webSettings.setAllowFileAccessFromFileURLs(true); // Enable HTML Imports to access file://.

Note: this is also using the Chrome webview (Android 4.4.3+).



来源:https://stackoverflow.com/questions/24708308/can-i-use-polymer-web-components-in-a-native-android-app-w-o-cordova

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!