I uploaded the map750.png file to the sdcard root directory, but when I try to show it in a webview with some text, only the text is displayed. Could you help me find what is wrong in the code? thanks.
setContentView(R.layout.webview); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setAllowFileAccess(true); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setBuiltInZoomControls(true); String html = "<html><head></head><body><p>hello</p><img src=\"file://mnt/sdcard/map750.png\" alt=\"alternativo\" /></body></html>"; mWebView.loadData(html, "text/html","utf-8");
I am editing a post to add the solution suggested by oneilse14, thanks !!
setContentView(R.layout.webview); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setAllowFileAccess(true); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setBuiltInZoomControls(true); String html = "<html><head></head><body><p>hello</p><img src=\"file://mnt/sdcard/map750.png\" alt=\"alternativo\" /></body></html>"; mWebView.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
source share