Posts

Launch a website as a mobile app using PhoneGap/Apache Cordova

How to launch a website as a mobile app using PhoneGap/Apache Cordova I spent some time recently trying to find out how to launch my website as a mobile app.  The information was available around the internet but since it took me a while, I thought I'd collate it here in one simple post for anyone who wants to do the same I decided to use Apache Cordova since it gave me the framework for developing an HTML5 site as a mobile app already, meaning all I really needed to do was plug my website into it.  Their getting started guide has good information on how to create a Cordova project - I used Android but you can use whatever means you wish A basic Cordova app gives you a way to launch the app with an HTML page that you use to display your app contents.  The trick then is make the page load your website which you can do in one of 3 ways: 1. Package your site inside the app. This means it loads fast and without an internet connection.  The downside i...

Android Daydream with Processing.js

Image
How to create an Android Daydream with processing.js I've spent some time working out how to get processing.js (a nice javascript graphics library ported from Processing ) to display an Android Daydream (basically a screensaver that activates when the device is docked or charging) I previously wrote about how to display an HTML page as a Daydream which forms the basis for this post.  Please see my earlier post for full details but to summarise you can load an HTML page in a webview like this webView.loadUrl("file:///android_asset/www/index.html"); Processing.js allows you to display Processing code as javascript in a page, so all you need to do is either embed the processing.js code or load the Processing PDE file containing the code as explained on the processing.js site I only had a couple of issues with it which were: 1. The js code seemed to run at a much  higher frame rate than my native Processing code such that my animation looked insane . In the end I...

How to bypass SSL certificate checking in Apache Cordova 2.2 on Android

How to bypass SSL certificate checking in Apache Cordova 2.2 on Android (or how to override CordovaWebViewClient in versions of Cordova 1.9+) I came across a strange issue where I was unable to access a secure URL using HTTPS.  At first I thought it was due to the Cordova whitelist since there was an issue with it in Cordova 2.1.  In order to access an external URL you have to whitelist them eg <access origin="https://www.wikipedia.org" subdomains="true"/> This didn't help though and even if I allowed all URLS using <access origin = "*"/> it still didn't work.  Strangely though it was only one secure URL I couldn't access, not all of them As it turns out, it was probably to do with the way Cordova assesses valid certificates.  When an Android app is signed and deployed it is deployed in 'production mode' which means that any secure URL accessed must have a valid certificate signed by a certificate authority (C...

Creating an Android Jelly Bean Daydream from a WebView

Image
One of the new nifty features on Android Jelly Bean 4.2 is the concept of daydreams (basically a screensaver but also displays when docked etc).  I wanted to create one that displayed an HTML page, which makes for prety easy development and this is how First of all, this assumes you have API 17 (Android 4.2) installed, otherwise you won't have access to the relevant Android class Android Daydream option You need to create a new class that extends android.service.dreams.DreamService and override the onAttachedToWindow() method which is what is called when the service starts up.  In here all you really need to do is create a new WebView as normal and attach it.  Example code below import android.annotation.TargetApi; import android.service.dreams.DreamService; import android.webkit.WebView; @TargetApi(17) public class MyDreamService extends DreamService {   @Override   public void onAttachedToWindow() {     super.onAttachedToWindow(); ...

Eclipse Appcache Generator - auto-generate HTML5 appcache files

HTML5 Appache I won't go into a full explanation here (if you want a tutorial the  HTML5 Rocks  website) but HTML5 appache is a method of caching web content so that, when offline, it can still be accessed One method of doing this is to add a meta tag to each page specifying an appcache file, which will tell the browser to cache that page. But what if you want to tell the browser to cache everything when the site is first accessed? Well HTML5 has a way of doing that too - you still add the meta tag but also specify the files to be cached in the file. When it is accessed, those files will be cached. This though leaves you with a problem - how do you make sure you locate every file to be cached and add them to the file? This is where this plugin can help Plugin The Appcache Eclipse Plugin is a plugin for the Eclipse IDE that will check all your files for your site and add all html, image, css and javascript files to the appcache. Once the plugin is installed, all you n...

Running Jenkins CI on a Raspberry Pi

Image
I've had this idea for some time of running my own Jenkins CI (continuous integration) server for building my mobile apps.  That was exactly what I intended to run on my Raspberry Pi when it arrived.  Now it has arrived, I thought I would share an issue I had so that others with the same problem can also solve it My Raspberry Pi My Pi is running Raspbian, which is Debian based, so theoretically installing Jenkins is as simple as running apt-get: sudo apt-get install jenkins This certainly installed it ok, but for some reason, it wouldn't start up.  Searching google revealed on possible issue regarding Java versions - specifically that Sun Java currently doesn't run on the Raspberry Pi.  A summary of how to fix that issue is: sudo update-alternatives --config java then chose OpenJDK followed by a reboot of the Pi.Jenkins starts up as expected after boot. However, my installation had already installed OpenJDK, so that wasn't my issue As it turns out...

No cursor in Ubuntu linux 11.10

I've had this weird problem lately on Ubuntu 11.10 (64 bit) - I only seem to have a cursor in some windows and never in any of the system windows (desktop, unity bar etc). Well today it was winding me up so I decided to try and fix it A quick google got me this page: No Cursor in Ubuntu 11.04 with a Legacy Nvidia Card . Not the right version of Ubuntu I know, and I have no idea what video card I have either, as the system info shows it as 'unknown'. But I figured I'd try it anyway Steps from that page: 1. Open a terminal window 2. Stop the x server: sudo service gdm stop 3 Uninstall the nouveau driver: sudo apt-get --purge remove xserver-xorg-video-nouveau 4. Reboot the machine When I got the step 2 though, it said the gdm service wasn't found, so I just did step 3. This unfortunately stopped the cursor moving at all! So I reinstalled the nouveau driver, and now it works! Now idea why! So for anyone who needs this, my steps were: 1. Open a terminal ...