• 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

html file input does not work in android WebView

 
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Everything in my android web app is working as expected except the html file input fields coded as in webpage.When i click on the button supposed to load the resources in which the files can be chosen from, it does not respond. Meanwhile in google browser, it works fine. My webview android code is as follows:



What am i missing?





 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WebView is an embedded browser control, but it's not fully autonomous. For many tasks, it relies on the application that is embedding it to perform some actions.

Showing file chooser dialog, showing javascript alert popups, etc. are some such tasks where the WebView just provides callbacks to the application and expects the application to display appropriate views like a file open dialog or message popup.

The application is expected to subclass WebChromeClient and perform these tasks, like displaying dialog.
The "Chrome" in WebChromeClient refers not to Google's Chrome browser, but as a general term typically used by user interface toolkits to refer to windowing and windowing decorations.
This discussion has the solution you need (apparently, this concept is a bit hacky in the Android implementation of WebView compared to more saner implementations in other platforms like JavaFX).
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Karthik, the link was very helpful. However, i wasn't able to get the camera available in the resources that can be picked.




 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

get the camera available in the resources


I'm not sure I understand. What do you want the user to see when they click on the file chooser button?
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want the user to be able to pick the camera and snap a picture which can then be uploaded as if it was taken from an image folder like Gallery. When i call the app with google browser, the camera is available in the items list loaded when i click on 'choose file' button. Hope i am understood.



 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I understood now.
If Google browser app is showing Camera in the chooser, it's because its WebChromeClient implementation has been coded that way.
Your WebChromeClient too should customize your chooser to include Camera. Try the code in this blog.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i fix this issue here https://youtu.be/jA9TCP6Y7uU
 
I like tacos! And 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