• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can Android web apps access content:// URLs?

 
Ranch Hand
Posts: 90
1
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 23
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Daniel Trebbien
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 90
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 23
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
Daniel Trebbien
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Damon Oehlman wrote:Did the same situation work for the HTML just running through the browser?



Yes:

 
Daniel Trebbien
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It also works with Android 1.5:

 
author
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Seriously? That's what you're going with? I prefer this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic