[Android] Parsing JSON with JsonReader

Back in Parsing JSON with JSONObject, I covered parsing JSON using JSONObject, where the object is created after reading the entire data into a String. Here, the same application will be created, but it will JsonReader instead. The source code for the demo can be downloaded from the Github repository.
Read more of this post

Advertisements

[Android] Allowing the user to enter a filter for a ListView

Back in Using an ArrayAdapter to Control a ListView’s Data, I wrote about filtering a ListView using its setTextFilterEnabled method. One of the comments reminded me that that not all devices have a physical keyboard and the virtual keyboard does not always show when entering the filter. For devices that do not have a physical keyboard, you could ask the InputMethodManager to display the virtual keyboard:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(getListView(), 0);

Read more of this post

[Android] Parsing JSON with JSONObject

Android provides JSONObject and JsonReader for parsing JSON. JSONObject has been around since API level 1 (the first Android release), whereas JsonReader has been around only since API level 11 (Android 3). Here, we’ll look at using JSONObject using a demo.

Read more of this post

[Android] Downloading and Displaying RSS Content

RSS feeds list the latest content added to a site. The sample in this post demonstrates how to obtain RSS content and display the latest item. It will cover:

The sample code can be downloaded from the GitHub repository.

Read more of this post

[Android] Using Frame Animation to Recreate the Flashing Arrow

Previously, I wrote about creating a simple animation of a flashing arrow using timers to hide and display a view at regular intervals (see A Simple Way To Make View Flash on Top of Another View). Another way to do this is to use Frame Animation, which is created by displaying a series of frames. Frame animation is actually covered in the Android Dev Guide, under View Animation. Here, using the same steps as described in the guide, the animation of the flashing arrow from the previous post is recreated.

Read more of this post

[Android] A Simple Way To Make View Flash on Top of Another View

[Android] Simple Flashing a View on Top of Another View

Flashing an image is a simple animation that can be achieved by laying an image on top of another and toggling the visibility at regular intervals. In Android, a View can be placed on top of another View, with a FrameLayout. Views can also be hidden and displayed by changing its visibility, through setVisibility. To demonstrate this method, I’ve prepared a small example of an arrow that flashes over a rocket when the rocket is clicked (the rocket and arrow clipart were obtained from Open Clip Art Library). The source is available from my Github repository.

Read more of this post

[Android] Using Projects to Separate Content Provider from Application Code

Content providers can be used to store and share data between two or more applications. The applications are usually independent of each other and they do not need to know the content provider stores and retrieves its data. Instead of lumping all of them together in one project, I generally find it easier to work with when they are separated out into their own individual projects. In this example (downloadable from here), this is separated in to four projects:
Read more of this post