File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes Can Android web apps access content:// URLs? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Can Android web apps access content:// URLs?" Watch "Can Android web apps access content:// URLs?" New topic
Author

Can Android web apps access content:// URLs?

Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 44
Part of one Android app that I have written is a custom content provider that basically stores JPEG images. Using the native ImageView widget, I can specify its "image URI" to a content URL that is handled by my content provider's openFile override.

Is an Android web app also able to access content:// URLs via, for example:

That might be wishful thinking, but at least conceivably the app could use the native functionality-bridging technique of PhoneGap to expose data at content URLs to the web app. Maybe this has been done already.
Damon Oehlman
author
Greenhorn

Joined: Jan 26, 2011
Posts: 23
You've had these questions brewing for sometime haven't you Daniel. I have to admit I don't know the answer to this one, but I'll definitely investigate. My gut feel is that in a PhoneGap wrapped application might be able to, but in a web app presented through the browser might not.

Is the application you have built available in the Marketplace? If not, I'll put together a test app at some stage and test for both situations.

Cheers,
Damon.


Damon Oehlman
@DamonOehlman - Web - Blog
Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 44
Damon Oehlman wrote:You've had these questions brewing for sometime haven't you Daniel.


Yes

Damon Oehlman wrote:Is the application you have built available in the Marketplace? If not, I'll put together a test app at some stage and test for both situations.


Unfortunately my app is not available in the Marketplace just yet.

Since I have the app, I will also try to code up a test PhoneGap app to access one of the content provider images from HTML. It might take me a bit of time, though.
Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 44
Daniel Trebbien wrote:Since I have the app, I will also try to code up a test PhoneGap app to access one of the content provider images from HTML. It might take me a bit of time, though.


Interesting! I checked with Android 2.3 and the HTML img tag is able to pull an image from my custom content provider.

I set up a basic PhoneGap-based app and added an img tag to the main HTML file, setting its image URI to the content URL of one of the images that are managed by my custom content provider. The correct image showed up on the screen, indicating that the HTML engine is able to retrieve files at content URLs.

What remains to be seen is whether the HTML engines of older API levels also support this and whether the Javascript engine can also access files at content URLs (e.g. with XMLHttpRequest).
Damon Oehlman
author
Greenhorn

Joined: Jan 26, 2011
Posts: 23
Daniel Trebbien wrote:Interesting! I checked with Android 2.3 and the HTML img tag is able to pull an image from my custom content provider.


Awesome Daniel, I think is a good example of how you can really use web and native together for writing apps for Android. Did the same situation work for the HTML just running through the browser?
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369

I checked with Android 2.3 and the HTML img tag is able to pull an image from my custom content provider.

Thanks for sharing the findings!


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 44
Damon Oehlman wrote:Did the same situation work for the HTML just running through the browser?


Yes:

Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 44
It also works with Android 1.5:

Sebastien Blanc
author
Ranch Hand

Joined: Nov 18, 2004
Posts: 33
Daniel,
That'a a very nice feature discovered !
But that's mean you create a close binding between your local device and the Web App, however let's stay pragmatic I will help in many situations.


Sebastien Blanc
Pro Android Web Apps: Developing HTML5, JavaScript, CSS, and Chrome OS Web Apps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can Android web apps access content:// URLs?
 
Similar Threads
Analogue clock
degrading
database data -to-> List view, how
Is it possible to build a native GUI within an Android web app?
How to handle screen orientation changes