• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html file input does not work in android WebView

 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • 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?





 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • 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
  • 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 C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • 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
  • 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 C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic