Tag Archives: Guides

How to check network connectivity in Android

This tutorial shows how to check whether your Android phone is currently connected to a network or not (e.g. Wi-Fi, 3G etc.).

A while back, I wrote a tutorial on how to dynamically monitor network connectivity in Android. However, sometimes all you want is to check if your phone has an active network connection at any given time (i.e. not to constantly monitor its status).

Continue reading

How to format string resources in Android

Resource files are one of the major strength in Android SDK that allows you to separate presentation from application logic. String resources in particular helps to effectively manage multi-lingual applications with ease.

In this tutorial, I will be showing how to use formatted string resources in Android. In addition to discussing the benefits of using formatted strings, the tutorial will show (a) how to define formatted string resources in xml, and (b) how to problematically use them when developing applications.

Continue reading

Liferay Part 2 – Setting up Liferay extensions environment

This is part 2 of an ongoing series of articles about my experiences with Liferay. In this article I will be providing step-by-step instructions on setting up an extensions environment with Liferay.

If you haven’t already set up a Liferay installation (with an application server), please refer to my previous blog post here.

Other articles of the Liferay series:

  1. Setting up Liferay with MySQL database
  2. Setting up Liferay Extensions environment
  3. Inter-portlet communication (both within a war and different wars)
  4. Step-by-step guide to creating a Liferay Hook
  5. Customizing Liferay login process

Continue reading

ActionBar design pattern example for Android

ActionBar is a user interface (UI) design pattern found in Android that allows users to quickly perform common actions within your application. ActionBar replaces the traditional title bar with a more featured and consistent UI. Popular applications that use this pattern include Facebook App and Twitter App. ActionBars help us to:

  • Have a dedicated UI space for commonly used actions in your applications to increase user engagement (e.g. Search, Refresh, display status etc.)
  • Have a consistent look and feel across all activities
  • Allows the user to perform common/key actions quickly without having to use the menu

Though framework support for ActionBars has been added in Android 3.0+ (Honeycomb), developers are required to implement it from scratch for non-tablet versions of Android. The aims of this tutorial are two-fold; Firstly to demonstrate how to build an ActionBar widget from ground up, and secondly to illustrate how to use the ActionBar in your application.

Figure 1 shows an Activity with the ActionBar we are planning to implement in this tutorial.

Figure 1: Action Bar Example

Continue reading

Creating multi-line EditText in Android

This is a small guide demonstrating how we can use Android EditText controls to create multi line text inputs.

Approach #1
The simplest way to create a multi line text input is using the following xml snippet:

XHTML
1
2
3
4
<EditText android:id="@+id/txtMultiLine"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:text="Default text" />

This will create a EditText view that displays the default text as shown in Figure 1 (a). When you enter new lines, the EditText will grow vertically (Figure 1 (b)). This might not be desirable in actual applications, as your layout becomes too fluid; potentially pushing important information out of user’s view.
Continue reading

How to monitor network connectivity in Android

Android devices have multiple network interfaces (e.g. WiFi and 3G/4G etc.) that allows them to go online and be connected to the outside world. At the same time, these network interfaces are prone to intermittent disconnection (for example, due to location, weather etc). Having knowledge of when the phone is connected (or disconnected) helps applications to act smartly when communicating over the internet. An example is automatically resuming pending downloads – without user intervention – when your network connection comes back online.

The following guide shows how you can monitor the network connectivity in Android, so your application can respond better when the network connectivity changes.
Continue reading

How to specify maximum length for EditText in Android

Often you might want to limit the number of characters a user can enter into your EditText control in Android. There are two ways to accomplish this:

  1. Using XML (e.g. layout or style)
  2. By code

Continue reading

Sharing information (objects/data) between Activities within an Android application

  • When developing Android applications, most of the time we need to share information (whether it be primitive data or complex objects) between different Activities. For example, we might want to pass in some data to initialise the views within a new Activity, or we might want to reuse a Database Helper across all our Activities to improve performance.

There are several different means of accomplishing this seemingly trivial task. However, picking the best option that suits your needs can be a daunting task for a novice Android developer! I aim to summarise few methods of sharing information between Activities and discuss when to use each one.

Continue reading

How to setup Zend Framework with Apache on Windows

Zend Web Framework is one of the most popular PHP frameworks out there to ease the construction of web sites. Though, there are lots of online tutorials on how to set it up using Apache, details are bit sketchy on getting everything to work on Windows machines. I was following several online tutorials, including the official tutorial from the Zend website itself, but kept running into various problems associated with getting Apache and Zend to work properly.

I am sure I am not alone with these issues, and compiled a small guide to show how to get Zend framework working on your windows machine (tested on XP, Vista and Windows 7) using Apache web server.
Continue reading

How to display borders in Table Layouts

According to the Android developer guide, border lines are not displayed for table layouts. However, often you will find the need to do things such as having vertical separators between table cells and borders around table rows. There are two different methods that I can think of to achieve this. Continue reading