Tag Archives: Android

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

Introduction to working with kSOAP2 in Android

This is an introductory tutorial showing how to consume SOAP-based web services in Android using the kSOAP2 library.

How to use kSOAP2 library in Android

Despite rising popularity of RESTful services, there are still a significant number of SOAP-based web services around that are being consumed by mobile applications; specially when working in the enterprise world. Android does not have native support for web service consumption, and this handy light-weight library called kSOAP2 allows Android applications to easily and efficiently consume SOAP-based web services.

In this tutorial I will show you how to use kSOAP2 in Android to consume a publicly available SOAP-based web service. A fully working example of an Android project illustrating the use of kSOAP2 can be found at GitHub.

Continue reading

Scrabble Assistant (Android) v2.0.0 is released

The latest versions of Scrabble Assistant Lite and Scrabble Assistant Pro for Android are now out in the Android market!

You can download them from:

Please feel free to leave your feedback and suggestions here! Don’t forget to rate the application and leave a comment on the Android Market if you find this useful!

Thanks!

Change Log for v2.0.0 (Pro version)

  1. Added support for SOWPODS/CSW 2012 dictionary (with 270163 words).
  2. Displays the title of the currently selected dictionary as part of the application title.
  3. Fixed issue where the anagrams are not being generated property with TWL/OWL dictionary.
  4. Minor UI improvements (help text and labels)

Change Log for v2.0.0 (Free/Lite version)

  1. Added support for SOWPODS/CSW 2012 dictionary (with 270163 words).
  2. Displays the title of the currently selected dictionary as part of the application title.
  3. Can enter up to 7 characters when performing anagram searches. The search results are still restricted to 6 characters.
  4. Fixed issue where the anagrams are not being generated property with TWL/OWL dictionary.
  5. Minor UI improvements (help text and labels)

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

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

Scrabblet version 1.1.0 released

I released the second version of Scrabblet (A word assistant application for Android mobiles) today. This includes addition of a new feature to display word scores against search results, UI facelift to improve usability and few performance tweaks.

New main screen for Scrabblet Pro

Have a go at the free version using the QR code below or going directly to the Android Market on your phone!

QR code for Scrabblet Lite

Click through to read the full change log.
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