Posts

Showing posts from November, 2012

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();     // Allow user touch     setInt