javascriptandroidhtmlwebviewapp-inventor

Implement local Html in WebView with App Inventor, it doesn't work input


Implement local Html in WebView with App Inventor.

Local HTML in App Inventor enter image description here

when I try to use "input" for pick a image in cellphone, doesn't react...

<html >
  <head>
    <meta charset="UTF-8">

<input type="file" id="fileElem" multiple accept="image/*" style="display:none" onchange="handleFiles(this.files)">
<a href="#" id="fileSelect">Pick some files</a> 

<script type="text/javascript">

  window.URL = window.URL || window.webkitURL;

var fileSelect = document.getElementById("fileSelect"),
    fileElem = document.getElementById("fileElem"),
    fileList = document.getElementById("fileList");

fileSelect.addEventListener("click", function (e) {
  if (fileElem) {
    fileElem.click();
  }
  e.preventDefault(); // prevent navigation to "#"
}, false);
  
</script>

I use WebView in app inventor. The Html is a local file. I only can use style sheets and libraries in the same directory as the main html file.


Solution

  • It is not possible to use the webviewer component to pick files in App Inventor.

    The webviewer is no full browser and you can't pick files like this. You will have to use the activity starter for that, see for example How to pick a file from SD card.

    Btw. generally you can use style sheets and libraries together with the webviewer...

    If you use html files including js and css files, which use a directory structure, you have 2 options:

    1. upload all files into the assets of your app and modify all paths inside all html, js and css files to use that main directory,
    2. or (probably easier) download your project (aia file) onto your computer, make a backup just in case (you know to have backups is always recommended…) open it using 7zip, drag your complete directory structure inside subdirectory assets, save the modified project (aia file) and upload the modified project to App Inventor