This may seem like a strange problem, but I'm curious to know if this will work. I am working on POC and therefore must either prove or disprove that this works or not.
The user interface in the Android application would be native (Java + XML layouts) + some other device access functions (e.g. Camera / File System, etc.).
There is a JS library that I created that has several functions that perform an Ajax post and receive requests.
In the application, I have an invisible Webview where I load empty HTML (referring to this JS library). And in this WebView, I introduced JavascripInterface. Thus, in essence, the user interface would be native, and you have never seen Webview. This is just a host that provides access to my JS library to its own code.
Now, with some actions in my user interface, I call JS functions in Webview, which, in turn, tries to make an ajax call (loadUrl calls ex. Javascipt: functionName ()). But these challenges fail without visible errors.
Note: This same HTML file works if I download it to my desktop browser. AJAX call succeeds.
But, when I initiate Ajax calls through JavascriptInterface (or webview.loadUrl ()) calls, they fail with a response status of 0.
Everything except AJAX, such as simple function calls, warnings, and callbacks through the javascript interface, works fine.
Q: I know that this is a strange and impractical way to do something. But, will this work / ?
Update: Even after installation
setBlockNetworkLoads (false)
it still doesn't work.
I tried to log JS calls and errors and got this error.
The X-Requested-With request header field is not allowed by Access-Control-Allow-Headers.
Any idea how to solve this?