Wednesday, December 30, 2009

A TabWidget offers the ability to easily draw an interface that uses tabs to navigate between different views.

Start a new Android Application, named AndrodTab extends TabActivity.

To use TabWidget, a TabHost have to be used to contain the entire layout of the Activity. A TabHost requires two descendant elements: a TabWidget and a FrameLayout. In order to properly layout these elements, we've put them inside a vertical LinearLayout. Otherwise, the TabWidget and FrameLayout will overlay each other. The FrameLayout is where we keep the content that will change with each tab. Each child in the FrameLayout will be associated with a different tab.

getTabHost() returns a reference to the TabHost. Then call addTab() for each of the tabs to add them into the TabHost. setIndicator() set the text for the tab button, and setContent() define the View associate with the tab. At the end, call setCurrentTab() to define which tab should be opened by default.

Sunday, December 27, 2009

ExifInterface is a class for reading and writing Exif tags in a JPEG file. Here is a simple exercise to read Exif tags. To make it simple, it will read a fixed JPG file from SD Card. The name and path of the JPG file is hard coded.

Refer to the article "Create SD Card in Android Emulator and copy files into, in Eclipse, Emulator and DDMS" to copy a JPG file with Exif into SD Card. And also, you have to update the program code with your own path and file name.

Create a Android Application, AndroidExif, with the following setting.

Wednesday, December 23, 2009

The Android Scripting Environment (ASE) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface.

It's (may be) the last article in the series of AndroidMapper. Here, methods exitOk() and exitCancel() in AndroidMapView were implemented to return or ignore the updated location back to the main activity, AndroidMapper. As you know, a application return nothing after processed is useless!

In exitOk() method in AndroidMapView, the updated location will be packed inside Bundle, and finish() with RESULT_OK.

Monday, December 21, 2009

Further works on the exercise, AndroidMapper. A options menu will be added in AndroidMapView using XML; with options of OK, Cancel, Reload and Help.

Reload: is used to reload the initiate location.Help: display the help message.OK and Cancel: not yet implemented. They will be used to return to the last Activity, AndroidMapper, with or ignore the updated location.

Saturday, December 19, 2009

Google announced working with Stack Overflow, a collaboratively edited question and answer site for programmers, to improve developer support, especially for developers new to Android. In essence, the Android tag on Stack Overflow will become an official Android app development Q&A medium. Google encourage to post beginner-level technical questions there. It's also important to point out that Google don't plan to change the android-developers group, so intermediate and expert users should still feel free to post there.

Thursday, December 17, 2009

Google just announced the new device dashboard of Platform Versions. It provides information about deployed Android-powered devices that is helpful to developers as they build and update their apps. The dashboard provides the relative distribution of Android platform versions on devices running Android Market.

The option items is added to the option menu in the method onCreateOptionsMenu(), in which initialize the contents of the Activity's standard options menu.

Because it's only one item in the menu, Menu.add(CharSequence title) is used to add item to the menu. Otherwise, Menu.add(int groupId, int itemId, int order, CharSequence title) or Menu.add(int groupId, int itemId, int order, int titleRes) have to be used.

onOptionsItemSelected() will be called whenever an item in options menu is selected. Also, because it's only one item in the menu, so there are no need to check which item have been selected, otherwise, you have to check the itemId.

Friday, December 11, 2009

layoutopt is a command-line tool that helps you optimize the layouts and layout hierarchies of your applications. You can run it against your layout files or resource directories to quickly check for inefficiencies or other types of problems that could be affecting the performance of your application.

Wednesday, December 9, 2009

In the last exercise, Move the marker on MapView, user touch on screen to pan the Map and update marker. It's very confuse with the BuiltInZoomControls function. So I separate the zoom function outside the MapView in this exercise. It's a SeekBar under the MapView, user can change the zoom level by sliding on the SeekBar.

If user Touch on screen without moving, it will be treated as update marker, the marker will be place on the new location, and it will be centered on the MapView. If user Touch on screen and Move, it will be treated as pan the MapView, the marker will not be changed.

The main logic is in the method onTouchEvent(MotionEvent arg0, MapView arg1), ACTION_UP, ACTION_DOWN and ACTION_MOVE cases.

((int)arg0.getX(), (int)arg0.getY()) is the on-screen pixel coordinates, it can be translated to latitude/longitude(GePoint) using Projection.fromPixels.

Sunday, December 6, 2009

MOTODEV Studio for Android is a Complete Development Package: One installer ensures an integrated development environment with Eclipse 3.5 and Android Development Tools (ADT) plus automatic download and configuration of the latest Android SDK.

Tuesday, December 1, 2009

In the last exercise, Display a marker on MapView, using Overlays, a marker will be displayed in Mode 1 (with starting location) only. In this exercise, current center location of the Map in Mode 0 (without starting location) will be retrieved using the method MapView.getMapCenter(). Such that the appearance of both mode will be kept consistance.

To achieve it, AndroidMapView have to be modified, to add function in onCreate() to handle Mode 0.