Beginning Android 3 is a book about the fundamentals of Android application development written by Mark Murphy. This post has some notes from the book. The book itself has much more information as well as helpful examples.
• Steps for getting started:
1. Set up Java
2. Install the Android SDK
3. Install the ADT for Eclipse (if you plan to use Eclipse)
4. Install Apache Ant (if you plan on using command-line build tools)
5. Set up the Emulator
6. Set up the Device
• When you create a new Android project, these items are put in the project’s root directory:
AndroidManifest.xml: an XML file that describes the application and components
bin/: the directory that holds the application after it’s compiled
libs/: the directory that holds any third-party JARs required by your application
res/: the directory that holds resources such as icons and layouts
src/: the directory that holds the application’s Java source code
• The MOTODEV Studio is a set of add-ins for Eclipse that offers more Android-related development features.
• The <supports-screens> element in the AndroidManifest.xml file enumerates the screen sizes you support.
• The onCreate() method is invoked when an activity is started.
• DroidDraw is a dedicated Android GUI designer.
• You can create a label by creating a TextView instance.
• ImageView and ImageButton are used for embedding images in activities.
• You can toggle whether or not a widget is enabled via setEnabled() and see if it is enabled via isEnabled().
• Three commonly used containers are LinearLayout, RelativeLayout, and TableLayout.
• ScrollView is a container designed to assist with implementing scrolling containers.
• The android:inputType attribute takes a class plus modifiers in a pipe-delimited list.
• The classic list box widget in Android is known as ListView.
• GridView gives you a two-dimension grid of items to choose from.
• The AutoCompleteTextView incorporates autocompletion.
• The Gallery widget is a list box that is laid out horizontally and can be used for previewing images.
• All View objects have getTag() and setTag() methods that let you associate an arbitrary object with the widget.
• The DatePicker and TimePicker widgets as well as the DatePickerDialog and TimePickerDialog are used for helping users enter dates and times.
• These widgets and containers set up a tabbed portion of a view: TabHost, TabWidget, FrameLayout
• The view-flipping logic from tabs is in the ViewFlipper container.
• SlidingDrawer is a sliding-drawer container.
• Some other widgets available in Android are: CheckedTextView, Chronometer, Gallery, MultiAutoCompleteTextView, QuickContactBadge, ToggleButton, ViewSwitcher
• The WebView widget can embed the built-in web browser as a widget in your app.
• The two main ways to get content into the WebView are with loadUrl() and loadData().
• WebView offers these ways to perform browser navigation: reload(), goBack(), canGoBack(), goForward(), canGoForward(), goBackOrForward(), canGoBackOrForward(), clearCache(), and clearHistory()
• You can adjust the settings of the WebView widget via the WebSittings instance returned from calling the widget’s getSettings() method.
• The onCreateOptionsMenu() callback receives an instance of menu.
• A Toast is a transient message and does not take focus away from the currently active Activity.
• An AlertDialog can be constructed with the Builder class.
• The onCreate() method is called when an activity is started and the onDestroy() method is called when the activity is shutting down.
• Other activity methods include onStart(), onRestart(), onStop(), onPause(), onResume(), onSaveInstanceState(), and onRestoreInstanceState().
• The ProgressBar keeps track of progress, defined as an integer.
• The most flexible means of making an Android-friendly background thread is to create an instance of a Handler subclass.
• To send a Message to a Handler, first invoke obtainMessage().
• To send a Message to the Handler via its message queue, use one of the sendMessage family of methods: sendMessage(), sendMessageAtFrontOfQueue(), sendMessageAtTime(), sendMessageDelayed(), or sendEmptyMessage().
• AsyncTask can make background operations easier and more transparent.
• After you create an intent, you need to pass it to Android and get the child activity to launch.
• The style attribute can be applied to a widget or container.
• Themes are styles applied to an activity or application, via an android:theme attribute on the <activity> or <application> element.
• RelativeLayout lets you control your layout while still adapting it to other screen sizes.
• The first step to supporting different screen sizes is to add the <supports-screens> element to your AndroidManifest.xml file.
Honeycomb and Tablets:
• If you want the action bar to appear on the screen, you need to include android:targetSdkVersion=”11″ in your <uses-sdk> element in the manifest.
• Fragments aggregate widgets and containers and can be placed into activities.
• A fragment inherits from Fragment and overrides onCreateView().
• Accessing files is accomplished by calling getResources().
• Reading and writing application-specific data files is accomplished by using openFileInput() and openFileOutput() on your Activity or other Context to get an InputStream and OutputStream, respectively.
• Another approach for working with application-local files is to use getFilesDir().
Data Stores, Network Services, and APIs:
• To access preferences you have three APIs to choose from: getPreferences() from within your Activity, getSharedPreferences() from within your Activity, or getDefaultSharedPreferences() on Preference Manager.
• To create and open a SQLite database, your best option is to craft a subclass of SQLiteOpenHelper.
• Calling execSQL() on your SQLiteDatabase creates tables and indexes.
• Using execSQL() is one approach for adding data to tables.
• Using the insert(), update(), and delete() methods on the SQLiteDatabase object is another way to add data to tables.
• The query() method takes the discrete pieces of a SELECT statement and builds the query from them.
• To start a download, first get access to the DownloadManager.
• A service extends either Service or an Android-supplied Service subclass.
• Service implementations have their own lifecycle methods, such as: onCreate(), onStartCommand(), onBind(), and onDestroy().
• The simplest way to work with a service is to call startService().
• In Android, you can raise notifications via the NotificationManager.
Other Android Capabilities:
• Requesting the use of other applications’ data or services requires the uses-permission element to be added to your AndroidManifest.xml file.
• The LocationManager and LocationProvider are used for accessing location-based services.
• MapView and MapActivity let you integrate maps into your applications.
• The TelephonyManager class is used for accessing the phone API.
• Some Android development tools include Hierarchy Viewer, Dalvik Debug Monitor Service, and Android Debug Bridge.
Alternative Application Environments:
• Alternative environments for Android application development include Native Development Kit, HTML5, PhoneGap, Rhodes, Flex, Ruboto, Mono for Android, App Inventor, and Titanium Mobile.