Ad

Visual Studio Cordova, Simple Way To "live Reload" On Android Devices?

Just started to check the workflow of developing cordova apps with Visual Studio 2015.

My question is, when debugging on actual android devices (assuming ver > 4.4) is there a way to achieve "live reload" (making changes in JS/CSS/HTML and these become active without restarting build process). I can undestand that adding/removing plugins from the project would be much more an issue for a live reload (due to native code that needs to be built) but for our javascript code, wouldn't that be just updating files on target? I don't really care for the automation of updating target without user interaction, i just need to avoid the time consuming rebuilding process, when frequent minor changes are needed. I read Ionic framework does that already, but do one needs to have ionic to do that? I also have seen/tested that with phonegap, but i prefer not go this way.

I am green in this, but i would assume that live reload would just involve a static http server pointing to our sources (managing the 'virtual' cordova.js and the like) plus something like changing the project's starting html to point to our server rather than the file (or even a 'reload' button on our app). Isnt that the case? I guess im wrong somewhere, otherwise i would expect to see that as V/S standard issue. Just saying. If not a V/S thing, is there a tool/plugin out there to install for that?

Sorry for long question/post. Comments/directions much appreciated

Ad

Answer

My solution to this was to have the app dynamically download extra Javascript files via standard Cordova download methods and then add the link to them in code. They execute the moment you add the HTML Script tag to the index page.

Not much of an answer, but it might lead you in the right direction.

Edit:

Try something like this to download the script:

var ft = new FileTransfer();
ft.download([VARIOUS PARAMS YOU CAN FIND ONLINE]);

And this to include in the project:

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = [PATH YOU GOT FROM THE DOWNLOAD ABOVE];
var head = document.getElementsByTagName('head')[0];
head.appendChild(script);

Sorry for the non-functioning code, but it's all I have time for at work! XD

Ad
source: stackoverflow.com
Ad