My Android PhoneGap application works completelly as expected when I copy all the web files (html, JS, CSS...) to the www folder of the project, and compile the application with these files. But when I do not copy them, and make a redirection to my Web Server containing these files (i.e. in the WWW folder there is only one file: index.html with a redirection to my server) phonegap does not work in the application anymore.
Is there a way to get phonegap to work, when the application content files are delivered by a remote server and not compiled with the application?
It can be done. Nothing can prevent you from doing that.
Phonegap + Android :
In your main activity class, method onCreate change loadUrl to:
super.loadUrl("http://.../index.html");
iPhone + Phonegap ia another story, still it can be done. Because there's a lot of changes here's a tutorial: http://www.joeldare.com/wiki/open_a_url_in_phonegap
One more thing, you must enable internet connection for Phonegap.
As you are using the android platform add this line to your AndroidManifest:
<uses-permission android:name="android.permission.INTERNET" />
Ah, one more thing, a viewport meta tag must be set in your html file.
Related
I have a website, a set of HTML, JS, and CSS files, all this successfully works under Apache Cordova via WebView on Android.
I want to run it on Delphi, via TWebBrowser, but if I open index.hml via file:// then JS scripts will not get access to local files. Actually, the same thing happens on a PC, too.
I see the solution as follows: raise your HTTP server and connect to it from TWebBrowser. If my idea is correct, the actual question is: What is the reason to raise the WebServer for Android?
I am using Delphi 10.3 CE.
When you say android application I understand its a .apk executable. But When you say developing android application using html, does it mean we still get a .apk file or when we develop using html, is it then called as android web development, which means you won't get a .apk file. But you get a html file that runs on android browser. Is that a correct statement. Because apart from Java and C# Xamarin which will produce a .apk file, I dont think html--->.apk file never happens.
So .apk file means apps similar to windows applications, and using html means we
create a mobile web application?
does it mean we still get a .apk file or when we develop using html
It can, if you are using tools like PhoneGap.
or when we develop using html, is it then called as android web development, which means you won't get a .apk file
An HTML5 Web app, particularly with offline caching, can feel a bit like an app. However, it would be written as a Web site or Web app and distributed as such, not distributed in the form of an APK.
I have a working web application. How would I refer to the index.html to this app's index.html?
super.loadUrl(“file:///android_asset/www/index.html”);
My web app already have the index.html. Do I just refer to that URL? Say my app is at:
www.myapp.com
Do I just type that address?
To quickly get it up and running put your index.html and any other html/images/css/javascript into zip file and upload to the PhoneGap build site. There's more to it that that but for a simple static app that will work.
I have a simple web app built with Phonegap and Android that call external ressources (js, css, html) from server instead of storing it in Phonegap assets folder. I prefer using external ressources because my server can deliver html pages taking in charge internationalization.
This web app work fine on my android device when WIFI is on but it fail when stopping WIFI. My index.html file delivered by my server contain a valid manifest file with correct mimetype ('text/cache-manifest') that list every files the app need to work.
My Android Activity class is supposed to have caching enable:
this.appView.getSettings().setDomStorageEnabled(true);
this.appView.getSettings().setAppCacheMaxSize(1024 * 1024 * 15);
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
this.appView.getSettings().setAppCachePath(appCachePath);
this.appView.getSettings().setAllowFileAccess(true);
this.appView.getSettings().setAppCacheEnabled(true);
It may worth mentionning that my app use ajax call with urls like /aaa/bbb/ to call web pages from server and I don't know if that may be the problem (l'm not calling physical pages directly like index.html)... However, this web app work well in desktop browser (Google Chrome) when offline...
Any idea what more can I do to enable this HTML5 cache feature on my Phonegap app?
Thanks a lot
After playing around for a while I get it to work. Here is some points you should verify when stucked with this type of caching problem:
Take care about url parameters passed with GET method... I was passing parameters when navigating between pages of my app and those parameters was making my urls different from the ones in manifest file making cache to fail.
When testing offline mode on my phone, I was only shutting down the WIFI thinking this was enough to trigger cached version of my app but it was not... As I was testing my app published under a local network IP (like 192.168.2.11), it appear that my app was trying to reach that IP trough the 3G network that was still ON... So use airplane mode when testing offline.
Not sure if this one was necessary as I read it on some others threads but I renamed my manifest file to cache.manifest.
Regards
Apparently you need "to fix the Android Shell Native App to enable HTML5 caching".
If you haven't already, please check out: http://tmkmobile.wordpress.com/2012/03/04/html5-offline-solution/
I am developing a similar system. What I did was I created the Phonegap webpages and stored them in the www folder of my WAMP server. Then what I do is I basically super.LoadURL("insert_ip_address_here/insert_name_of_folder_where_webpage_is_located") in the onCreate method and this loads the phonegap application perfectly (yes all you need is just only line of code in the Android app itself). However you still have to make sure that the config.xml, manifest and all configurations needed for phonegap are properly done (for instructions on this see https://www.adobe.com/devnet/archive/html5/articles/getting-started-with-phonegap-in-eclipse-for-android.html).
Let me know if this the path you choose to pursue. I can provide extra support with things like making the ip-address (in the line super.loadurl(...)) dynamic for the local system using multi-casting, etc.
If I create a html 5 application for a phone (using phonegap or Icenium) that calls a webservice which needs a username/password, can a person look at the code somehow or is the JavaScript compiled away or obstructed in some manner?
Assume in this case that the url is in a javascript file with username and password.
Neither Phonegap nor Icenium (both based on Apache Cordova) obfuscate or compile the JavaScript code of your app.
You can take any Cordova app for iOS or Android and simply unzip the .ipa or .apk package to reveal the HTML, CSS and JavaScript code that powers the app.
If its a regular user, then most-likely not.
But if you are asking this question because you want to prevent someone that is skilled want needs to see your app for code. Then the answer is:
Nothing is safe in your clients device. Not sqlite database, not built-int storage , and not source code( weather its compiled or not);