At startup, my Phonegap application loads a hosted application (cordova is loaded from there). In certain cases (events) I want to redirect the user to an html file that lives in the phone.
Is there a way to accomplish that?
I've tried redirecting to file:///android_asset/www/index.html but doesn't seems to work.
Maybe a PhoneGap plugin that exposes Android's loadUrl() to JavaScript?
EDIT: I'm using Phonegap 2.8
You can use navigator.app.loadUrl:
navigator.app.loadUrl("file:///android_asset/www/index.html");
Related
Hello i am working on a mobile magento theme. What i am looking is to embed or either cache the html, css and javascript files (do not know which is better!) to the application (local storage on phone) and retrieve the product catalog and related pictures from the database and online servers
My intention is to make the app have minimum load on startup and shows as normal native apps
Can you give some guidelines and routine to do so .
Thanks you.
You can either give PhoneGap a shot (http://www.phonegap.com), or try it yourself, since PhoneGap is nothing more than some small libraries to make native function (notifications, vibrating etc.) available for JavaScript calls.
If you just want to wrap your site into a native app, you can just put it inside a WebView, which runs exactly like the native Android browser.
If you want to use your html, css and js files to create an android app then the easiest way to attempt this is http://phonegap.com/
However, I would strongly urge you to build a native app (on Android) as Phonegap comes with tons of problems and less support.
I want you to open a link in my app via browser not in Appview. I ma making my html5 mobile app via xdk. I don't want to use cordova in my app as my app is heavy enogh and don't want to make it heavier because of just one link.
I saw this :
www.kidzout.com
But the problem is I must install Cordova InAppBrowser plugin for this to work. Do you have any solution without using Cordova or external plugins? Do you think is it possible at all?
You can open a link in the native browser(Mobile Safari, Android, etc.) from within a HTML5 Mobile app using the intel.xdk API formerly AppMobi.
In the head, include a reference to the intelxdk.js file.
<script src="intelxdk.js"></script>
Use this for opening your link:
Launch in Browser
For more information, go to http://www.html5dev-software.intel.com/documentation/jsAPI/device/launchExternal/index.html
If you are opening a remote URL in your webview and adding javascript is not an option, you can make a patch in native code.
Here I show the workaround for Android:
https://stackoverflow.com/a/35037737/813951
I have a problem implementing Disqus in an app created with sencha touch and phonegap. The web app developed by Sencha Touch Disqus is working fine, however when I make a build through phonegap to Android or iOS, the disqus comment doesn't show.
I implement the script in a Sencha x-Panel with HTML properties.
In order for the Disqus embed to load, it must come from a valid referrer - typically this referrer when on the phone is something like the file system path.
The ideal way to handle this is to host the Disqus embed on an external page and load that into your view. You can even load this on a static cdn using this example: https://github.com/disqus/DISQUS-API-Recipes/tree/master/mobile/js
I am making a Hybrid Application using cordova-cli. My requirement is that the first page in my application must redirect to a website. The entire data required for the application will be loaded into this website from some other data-sources.
The requirement is to access device native features such as camera, accelerometer etc. from pages on this website.
I am using
location.href="http://www.example.com";
to open the pages. I need a unified cordova.js file with all the plugins embedded into it.
Currently I am putting the individual plugins into the lib\android\plugin\android and by using the grunt -f command from grunt-cli, the cordova.js file recieved for android does not seem to produce expected results.
Can't be done I am afraid - because of the way Cordova interacts with the device.
What happens if, using a non-mobile device, you accessed the same website from elsewhere? The website will not know what on earth Cordova is.
Cordova interacts with the native code on the device, so requires this to handle the passing of JS-to-native, and vice-versa.
I am using Titanium to create a application for Android. The app uses webview to load external HTML5 webpages. The webpage uses a manifest to cache the page and some assets. This works fine on desktop browsers and third party app browsers in Android (Chrome).
When I view the page in a webview in the Titanium build app, it seems that the manifest is not used, the page just loads everything from the server. The same problem occurs when I use the build in browser of my phone (HTC one X).
What I am trying to accomplish is that the pages are offline available, so that internet is not required tot view cached pages. Is there a fix for this problem, or should I go look in another direction to solve my problem?
the manifest file:
CACHE MANIFEST
# version 1
leerlingen.html
jquery.js
style.css
handler.js
NETWORK:
*
First: Titanium provides much more than a WebView. If you planned to display only web pages you maybe should have a look at PhoneGap / Cordova which might fit your needs in a better way.
As you've noticed not all browsers support HTML5 Caching feature as expected. I can't say if it doesn't work for Android in general or only for your specific version because WebKit usually does support it but it depends of the used WebKit version. And this could be different.
EDIT: It seems that (in native android) this feature can be enabled as written here: Application cache in HTML5 doesn't work in Android PhoneGap application. This is currently not possible in Titanium (there might be inofficial tweaks i don't know but from http://docs.appcelerator.com this is not possible).
Personally i'd prefer another solution. Cache data by myself and display it if there is no network connection. But this depends on what you try to achieve. Having few content which doesn't change often this would make sense. Having dynamically changing data (like twitter stream for instance) this would be difficult. Also it depends on your users and where they want to access your app.
And there is an open question: When you want to use all the caching features why do you want to create an app? Creating a simple mobile webpage would do the same job. When creating an app i wouldn't use the Caching Features of HTML 5. You should keep all the static resources in your app and simply load data from the network. This can be achieved by both Titanium and PhoneGap / Cordova. Titanium is more useful for a native UI and some native Features while PhoneGap / Cordova would be more appropriate for HTML5 based layout.
Just in case someone else is running in the same problems that i was facing, here is what i've done. HTML5's application cache does not seem to work in the build-in browser of Android and with that the webviews. In Titanium there seems to be no way to control the webview as to enable the application cache.
The work around for me was to use Titanium and it's httpClient function (Titanium.Network.HTTPClient) to request the files (HTML, CSS, javascript) and store it in the local app filesystem (Titanium.Filesystem).