Category Archives: Tutorial

Using Robotium with a Play APK

This tutorial will look at how we can use Robotium to run tests on Android applications where we don’t have the source code, only the APK from Google Play. It’s not meant as an extensive review of what Robotium is or how is compares to other testing frameworks, just the basics that are required to get started in a slightly less verbose fashion than the informative ‘official’ documentation. Robotium can be downloaded here and if you want to head straight to the Robotium documentation for this task, it’s here. Continue reading

Moving WordPress

OK, this is going to be a very short post, more of a mental note than a tutorial, about moving a WordPress install. The task was to move from sub.example.com to example.com where the files for example.com were to be stored in a folder rather than the root of the www directory (the www folder hosted multiple sites). Basically I followed this tutorial, skipping steps 12 – 15. I would add to this tutorial that you need to download and edit the following lines in your wp-config.php file;

define( 'WP_CONTENT_DIR', '/home/hosting/public_html/sub.example.com/wordpress-content' );
define( 'WP_CONTENT_URL', 'http://sub.example.com/wordpress-content' );

to reflect the new URLs

define( 'WP_CONTENT_DIR', '/home/hosting/public_html/example.com/wordpress-content' );
define( 'WP_CONTENT_URL', 'http://example.com/wordpress-content' );

This was the change that made everything appear as it should. From here I could re-apply my custom theme and have all my plugins show up without errors.

Embedding a Cordova WebView in a Native Android app

Sept 2013 – Updated to use cordova 2.9 – see github repo

A few months ago I wrote a tutorial on Hybrid apps and accessing native functions from an Android WebView. I made a comment that while Apache’s Cordova can do this fine, you wouldn’t use Cordova from within an app. Then I discovered you could embed a Cordova WebView within a native app. If you’re not familiar with Cordova, this means you can create an Activity within your native app which uses HTML5 and JavaScript to create the UI and access native functions and features via the Cordova API.

Continue reading

Accessing Twitter API 1.1 on Android

This tutorial covers the basics of using the Twitter API to access your own tweets, most likely with a view to displaying them in an app. Updated on Friday 13th September 2013, source code available on Github

Twitter API v1.0

On the 5th March, 2013, v1 of the Twitter API will be no longer be accessible. Currently, you can get access to Twitter REST API using unauthenticated HTTP requests. Continue reading

Builder Pattern

In Joshua Bloch’s ‘Effective Java’, the author discusses the use of the builder pattern as a way to efficiently instantiate an object which has many parameters (some mandatory, some optional). We’ll first look at two alternatives (Telescoping and Java Beans) before looking at the builder pattern.
Read full article

Android JavaScript Interface

This tutorial will show you how to access native features from a WebView, and how to pass data back to a WebView from native code. The former part, invoking native code from a WebView, is achieved through adding a JavaScript interface and is documented in the Android API guide here. The example in the guide causes an Android Toast to be triggered from the WebView. All very well, but what about having an app or part of an app that runs in a WebView, gets data from the Android OS and, rather than simply calling a native function like Toast, returns the data to the WebView UI? Read full article

Customising an Android Button

The stock android button can look a little dull and basic, so today I’m going to look at making a custom button.
Start with a generic android project (my target is 16, min version 7 – this will cause Eclipse to include the android-support-v4.jar which is needed for some of the xml statements in this tutorial) and navigate to your res/layout/yourlayout.xml layout xml. Read full article