Developing Android applications in Java – Session 1 – My Notes

Like last week, I attended the session on Developing Android applications in Java by Creative Techs and O’Reilly and here are my notes which I took during the session.

Demo Application

In this week’s session, he created a sample task manager app which can be used for maintaining list of things to track. This app was created using Android 1.6 with Google API support. You can download the source code of this demo app below.

The sample app will have two activities. One will have a simple data entry form which can be used to add tasks and the other to view tasks which were entered. Check the screenshots below to see how the sample app looks like.

android-taskmanager-1 android-taskmanager-2

Layouts

Tony (the instructor) briefly explained about the different types of layouts and for the sample apps he used Relative Layout. You can read more about the relative layout from the android documentation.

The major pain point in using Relative layout is that, the controls should be specified in the order in which they are referenced and not in the order in which they will be displayed.

EditText control

EditText control is an editable control which can be used to get user input. It is similar to the HTML textbox or the Java Swing JTextField.

You can read more about EditText control from android documentation.

Sharing data between views

An application can have multiple activities (views) and to share data between these multiple activities, the android framework provides a class called Application. This Application class can be accessed from all the activities of the app by calling the getApplication() of the Activity class. Tony explained this about this class and also used it in the demo app to store and retrieve tasks from multiple activities.

You can find this class in the TaskManagerApplication.java in the sample app. You can download the source code of this demo app below.

Safe cancelling

Tony also explained about how to listen to text changes and make sure the user is not moving away from the activity when there are unsaved work.android-taskmanager-3

You can check the cancel() method in AddTaskActivity class, where we will be showing an alert box (see screenshot) using the built in AlertDialog, whenever the user clicks the cancel button without saving the task that he has entered.

You can read about the AlertDialog class in the android documentation.

Source code

I have uploaded source code for yesterday’s session in github and you can download it from there. I am also working in this week’s homework and will be posting the explanation and source code once I am done.

You can also subscribe to my blog’s RSS feed or follow me in Twitter to receive updates about my notes for the next sessions.

Related posts

Tags: , ,

9 Comments so far

Follow up comments through RSS Feed | Post a comment

3 Tweetbacks so far

3 Trackbacks/Pingbacks so far

Leave a Reply

Your email address will not be published. Required fields are marked *