2

how can I show pictures in WebView without saving images into file system?

I have tried to implement my custom ContentProvider, but method openFile returns ParcelFileDescriptor that points into filesystem (or socket). My pictures are in filesystem, but in encrypted form.

I have tried also URL.setURLStreamHandlerFactory, but in android java it is useless (because custom streamHandler can be register in jvm that is not allowed).

I also try html code "img src=\"data:image.gif;base64,R0lGODlhiAAkAMQAANOOk...", but in embedded chrome it's not working :(

pls help

Sephy
  • 50,022
  • 30
  • 123
  • 131
Peter
  • 197
  • 1
  • 7

2 Answers2

1

There is a bug in Android you cannot load images with Base 64 on a webview like that(ur last approach)...

http://code.google.com/p/android/issues/detail?id=596

Check this link out may be you can try with this approach of using content providers

http://blog.tourizo.com/2009/02/how-to-display-local-file-in-android.html

http://www.techjini.com/blog/2009/01/10/android-tip-1-contentprovider-accessing-local-file-system-from-webview-showing-image-in-webview-using-content/

or

http://downloadandroid.info/2010/07/how-to-display-an-image-from-the-sdcard-in-webview/

DeRagan
  • 22,827
  • 6
  • 41
  • 50
  • 3
    I've got a mistake in html code: img src="data:image.gif;base64,R0lGODlhiAAkAMQAANOOk... correct is (typo in mimetype): img src="data:image/gif;base64,R0lGODlhiAAkAMQAANOOk... – Peter Aug 31 '10 at 13:27
1

The first link shows how this is done using the file system, and doesn't seem to resolve the problem described by peter. From what I saw, the only way to resole this is by using a MemoryFile:

Custom ContentProvider - openInputStream(), openOutputStream()

but specifications are not final and it's not implemented on all systems.

Did you find a better way? Is there a way to do it? Is there a way to read a Cursor from a webview?

Community
  • 1
  • 1
yoavr
  • 151
  • 2
  • 5