Beginner wrote:
> Hi,
>
> I'm trying to load an image (tried both gif and png) from my assets
> directory, into a webview.
>
> In my assets folder, I have an image called myImage.gif
>
> Here's my code:
>
> WebView data = (WebView) findViewById(R.id.data)
> data.loadData("<IMG HEIGHT=\"42px\" WIDTH=\"42px\" SRC=\"file:///
> android_assets/myImage.gif\" />", "text/html", "UTF-8");
>
>
> All that happens when I try it, is that I get a blank screen with a
> empty 42px/42px box.
>
> In logcat, I see the message:
>
> 03-30 00:21:14.398: DEBUG/WebCore(214): Console: Not allowed to load
> local resource: file:///android_assets/myImage.gif line: 0 source:
>
>
> What am I doing wrong?
Try loadDataWithBaseUrl() instead of loadData(), supplying some bogus
value for the base URL (e.g.,
fake://dagnabbit/would/somebody/explain/the/need/for/this).
See:
http://groups.google.com/group/android-beginners/browse_thread/thread/a66e63959bb89193/a7e8782c85076bf7
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---