Notes on Udacity Developing Android Apps

Notes as I follow through with Udacity's online course Developing Android Apps.

The discussion forum provides a place for discussions.

Declaring layouts: android

To use Fragment class, it depends on the Android version;
import (requires API 11 and above)
import; (requires API 10 and above)

Application Lifecycle

Activity between states.

Activity Lifecycle

When app starts the activity;
Sequence onCreate - onStart - onResume

When rotating the device
Sequence onPause - onStop - onDestroy - onCreate - onStart - onResume


Verify data contents with Toast. Within the fragment to be executed, use;

Toast toast = Toast.makeText(getContext(), "you did a click", Toast.LENGTH_SHORT );;


The Uri.Builder helps construct http and https URLs.

e.g. 1
Uri.Builder builder= new Uri.Builder();
        .appendQueryParameter("q", city)

e.g. 2
final String FORECAST_BASE_URL="";
builder= new Uri.Builder();
        .appendQueryParameter("q", param[0])


Android Permissions

Permissions needed


AsyncTask class simplify background thread creation and UI thread synchroization.

Getting the sample codes

Using git;
git clone
cd Sunshine-Version-2
// Show all branches
git branch -a
// Show only remote branches
git branch -r

git checkout 1.06_attach_adapter

Open Weather JSON

JSON URL samples

URL query for Sunshine app
requirements: 1 week, JSON format, city, metric

Geonames JSON site at

Android Studio 1.4 Keyboard Shortcuts

Ctrl+q View quick documentation
Ctrl+o List members of a class to populate in source
Shift+F6 Rename class, methods and variables with corrections to all places they are used (refactor)
Ctrl+o Override methods of base class
Ctrl+i Implement methods of base class

GIT references

Backup source files
git archive --format zip --output ../ 1.06_attach_adapter

Blog Archive