Table of Contents 1. Android Development 1.1. Android Operation System 1.2. Important Android components 1.3. Security and permissions 1.4. AndroidManifest.

xml 1.5. R.java, Resources and Assets 1.6. Activities and Layouts 1.7. Activities and Lifecyle 1.8. Context 2. Installation 2.1. Android SDK 2.2. Eclipse 2.3. Configuration 2.4. Android Source Code 3. Create an Android Emulator Device 4. Error handling 5. Your first Android project 5.1. Create Project 5.2. Two faces of things 5.3. Create attributes 5.4. Add UI Elements 5.5. Edit UI properties 5.6. Code your application 5.7. Start Project 5.8. Using the home menu 6. Menus 6.1. Menus 6.2. Project 6.3. Add a menu XML resource 7. Preferences and Intents 7.1. Overview 7.2. Using preferences 7.3. Run 8. Dialogs via the AlertDialog 9. TableLayout 9.1. Overview 9.2. Example 10. ContentProvider 10.1. Overview 10.2. Create contacts on your emulator 10.3. Using the Contact Content Provider 11. ScrollView 12. DDMS perspective and important views 12.1. DDMS - Dalvik Debug Monitor Server 12.2. LogCat View 12.3. File explorer 13. Shell 13.1. Android Debugging Bridge - Shell

13.2. Uninstall an application via adb 13.3. Emulator Console via telnet 14. Deploy your application on a real device 15. Thank you 16. Questions and Discussion 17. Links and Literature 17.1. Source Code 17.2. Android Resources 17.3. vogella Resources

1. Android Development
1.1. Android Operation System
Android is an operating system based on Linux with a Java programming interface. It provides tools, e.g. a compiler, debugger and a device emulator as well as its own Java Virtual machine (Dalvik Virtual Machine - DVM). Android is created by the Open Handset Alliance which is lead by Google. Android uses a special virtual machine, e.g. the Dalvik Virtual Machine. Dalvik uses special bytecode. Therefore you cannot run standard Java bytecode on Android. Android provides a tool "dx" which allows to convert Java Class files into "dex" (Dalvik Executable) files. Android applications are packed into an .apk (Android Package) file by the program "aapt" (Android Asset Packaging Tool) To simplify development Google provides the Android Development Tools (ADT) for Eclipse . The ADT performs automatically the conversion from class to dex files and creates the apk during deployment. Android supports 2-D and 3-D graphics using the OpenGL libraries and supports data storage in a SQLite database. Every Android applications runs in its own process and under its own userid which is generated automatically by the Android system during deployment. Therefore the application is isolated from other running applications and a misbehaving application cannot easily harm other Android applications.

1.2. Important Android components
An Android application consists out of the following parts:

Activity - Represents the presentation layer of an Android application, e.g. a screen which the user sees. An Android application can have several activities and it can be switched between them during runtime of the application. Views - The User interface of an Activities is build with widgets classes which inherent from "android.view.View". The layout of the views is managed by "android.view.ViewGroups". Services - perform background tasks without providing an UI. They can notify the user via the notification framework in Android.

Content Provider - provides data to applications, via a content provider your application can share data with other applications. Android contains a SQLite DB which can serve as data provider Intents are asynchronous messages which allow the application to request functionality from other services or activities. An application can call directly a service or activity (explicit intent) or ask the Android system for registered services and applications for an intent (implicit intents). For example the application could ask via an intent for a contact application. Application register themself to an intent via an IntentFilter. Intents are a powerful concept as they allow to create loosely coupled applications. Broadcast Receiver - receives system messages and implicit intents, can be used to react to changed conditions in the system. An application can register as a broadcast receiver for certain events and can be started if such an event occurs.

Other Android parts are Android Widgets or Live Folders and Live Wallpapers . Live Folders display any source of data on the homescreen without launching the corresponding application.

1.3. Security and permissions
Android defines certain permissions for certain tasks. For example if the application want to access the Internet it must define in its configuration file that it would like to use the related permission. During the installation of an Android application the user get a screen in which he needs to confirm the required permissions of the application.

1.4. AndroidManifest.xml
An Android application is described the file "AndroidManifest.xml". This file must declare all activities, services, broadcast receivers and content provider of the application. It must also contain the required permissions for the application. For example if the application requires network access it must be specified here. "AndroidManifest.xml" can be thought as the deployment descriptor for an Android application.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.vogella.android.temperature" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".Convert" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="9" />

</manifest>

The "package" attribute defines the base package for the following Java elements. It also must be unique as the Android Marketplace only allows application for a specfic package once. Therefore a good habit is to use your reverse domain name as a package to avoid collisions with other developers. "android:versionName" and "android:versionCode" specify the version of your application. "versionName" is what the user sees and can be any string. "versionCode" must be an integer and the Android Market uses this to determine if you provided a newer version to trigger the update on devices which have your application installed. You typically start with "1" and increase this value by one if you roll-out a new version of your application. "activity" defines an activity in this example pointing to the class "de.vogella.android.temperature.Convert". For this class an intent filter is registered which defines that this activity is started once the application starts (action android:name="android.intent.action.MAIN"). The category definition (category android:name="android.intent.category.LAUNCHER" ) defines that this application is added to the application directory on the Android device. The @ values refer to resource files which contain the actual values. This makes it easy to provide different resources, e.g. strings, colors, icons, for different devices and makes it easy to translate applications. The "uses-sdk" part of the "AndroidManifest.xml" defines the minimal SDK version your application is valid for. This will prevent your application being installed on devices with older SDK versions.

1.5. R.java, Resources and Assets
The directory "gen" in an Android project contains generated values. "R.java" is a generated class which contains references to resources of the "res" folder in the project. These resources are defined in the "res" directory and can be values, menus, layouts, icons or pictures or animations. For example a resource can be an image or an XML files which defines strings. If you create a new resources, the corresponding reference is automatically created in "R.java". The references are static int values, the Android system provides methods to access the corresponding resource. For example to access a String with the reference id "R.string.yourString" use the method getString(R.string.yourString)); Please do not try to modify "R.java" manually. While the directory"res" contains structured values which are known to the Android platform the directory "assets" can be used to store any kind of data. In Java you can access this data via the AssetsManager and the method getAssets().

1.6. Activities and Layouts
The user interface for Activities is defined via layouts. Layouts are at runtime instances of "android.view.ViewGroups". The layout defines the UI elements, their properties and their arragement. UI elements are based on the class "android.view.View". ViewGroup is a subclass of View A and a layout can contain UI components (Views) or other layouts

e. 1. can be used to release ressource or save data onResume() .always called if the Activity ends.yourvalue). The most important methods are:    onSaveInstanceState() . It also allows to define different layouts for different devices.xml.ProgressTestActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|keyboard"> </activity> 1. Used to save data so that the activity can restore its states if re-started onPause() . You should not nestle ViewGroups to deeply as this has a negativ impact on performance. A configuration change for examples happens if the user changes the orientation of the device (vertical or horizontal). because of an incoming call.8. Defining layouts via XML is usually the preferred way as this separates the programming logic from the layout definition.(ViewGroups).g. The following activity will not be restarted in case of orientation changes or position of the physical keyboard (hidden / visible). If a UI element needs to be accessed via Java code you have to give the UI element an unique id via the "android:id" attribute.7. This file specifies the view groups. You typically uses Java code to generate the layout if you don't know the content until runtime. By conversion this will create and assign a new id "yourvalue" to the corresponding UI element. In your Java code you can later access these UI elements via the method findViewById(R. for example if your layout depends on content which you read from the internet. e.g.called if the Activity is re-started. The activity is in this case restarted to enable the Android platform to load different resources for these configuration. To assign a new id to an UI element use "@+id/yourvalue". You can avoid a restart of your application for certain configuration changes via the configChanges attribute on your activity definition in your AndroidManifest. XML based layouts are defined via a resource file in the folder "/res/layout". A layout can be defined via Java code or via XML.called if the activity is stopped. can be used to initiaze fields The activity will also be restarted if a so called "configuration change" happens. layouts for vertical or horizontal mode. At any time the Android system may stop or destroy your application. their relationship and their attributes for a specific layout. You can also mix both approaches. In the emulator you can simulate the change of the orientation via CNTR+F11. Activities and Lifecyle The operating system controls the life cycle of your application.id. views. Context . <activity android:name=". The Android system defines a life cycle for an activities via pre-defined methods.

. the Location Service . Select the Google API 10 (Android 2.3. For details please see Eclipse Tutorial . Android SDK Download the Android SDK from the Android homepage under Android SDK download .content. e. We are using the Google version as this includes also the Google Maps which we might want to use later at a certain point. Installation The following assume that you have already Eclipse installed. I placed it under "c:\android-sdk-windows". The download contains a zip file which you can extract to any place in your file system.google. It is the interface to global information about the application environment. Select Android and enter the installation path of the Android SDK.3.g. Configuration In Eclipse open the Preferences dialog via Windows -> Preferences.4) version of the SDK.g.com/android/eclipse/ . Select Window -> Android SDK and AVD Manager from the menu.Context provides the connections to the Android system.The class android. Avoid using spaces in the path name otherwise you may experience problems later. Select "Available packages" and open the "Third Party Add-ons". 2. 2.1. As Activities and Services extend the class "Context" you can directly access the context via "this". 2.2. Context also provides the method which allows to receive Android services. Eclipse Use the Eclipse update manager to install all available plugins for the Android Development Tools (ADT) from the URL https://dl-ssl. 2. e.

Update site: "http://adtaddons. 3.com/svn/trunk/binedit/com.ide.Press "Install selected" and confirm the license for all package. Haris Peco maintains plugins which provides access to the Android Source code code. To define an AVD press the device manager button.android.googlecode.googlecode. Each configuration is defined via an "Android Virtual Device" (AVD).eclipse.ide. This emulator behaves like a real Android device in most cases and allow you to test your application without having a real device.4. press "New" and enter the following.source.binedit. During Android development it is very useful to have the Android source code available as Android uses a lot of defaults. You can emulate one or several devices with different configurations.update" and "http://adt-addons.com/svn/trunk/source/com.eclipse.android. . Use the Eclipse update manager to install two of his plugins. More details can be found on the project website .update". 2. Android Source Code The following step is optional. Create an Android Emulator Device The Android tools include an emulator. After the installation restart Eclipse.

.

This will make the second start of the virtual device much faster.We will select the box "Enabled" for Snapshots. . After (a long time) your device should be started. select your device and press "Start". At the end press the button "Create AVD".This will create the device and display it under the "Virtual devices". To test if your setup is correct.

3... Unable to open class file R. Project . 5.1. To solve this error select from the menu Project -> Clean. If you having problems with your own code you can use the LogCat viewer as described in LogCat Viewer .java. is missing required source folder: 'gen' 2. Create Project . The project could not be built until build path errors are resolved. Your first Android project 5.4. Several users report that get the following errors: 1. Error handling Things are not always working as they should be.

vogella.temperature".Tip This app is also available on the Android Marketplace. Enter the following. .android. Search for "vogella" for find this example. Select File -> New -> Other -> Android -> Android Project and create the Android project "de.

.

In Java you can access this data via the AssetsManager and the method getAssets(). Two faces of things The Android SDK allows to define certain artifacts. The following description tries to use the rich UI but for validation lists also the XML.2.g. You can switch between both things by clicking on the tab on the lower part of the screen.Press "Finish". This should create the following directory structure. in two ways. While "res" contains structured values which are known to the Android platform the directory "assets" can be used to store any kind of data. e. via a rich editor and directly via XML. . For example in the Package Explorer select "res/layout/main. strings and UI's.xml". 5.

Select the file "res/values/string.xml" and press "Add". .3.5. These attributes can be used in your UI definition via XML or in your Java source code.g. for strings and / or colors. e. Create attributes Android allows you to create attributes for resources. Select "Color" and enter "myColor" as the name and "#3399CC" as the value.

Convert!</string> <string name="app_name">Temperature Converter</string> <color name="myColor">#3399CC</color> <string name="myClickHandler">myClickHandler</string> <string name="celsius">to Celsius</string> <string name="fahrenheit">to Fahrenheit</string> <string name="calc">Calculate</string> </resources> 5.Add also the following "String" attributes. String Attributes Name Value myClickHandler myClickHandler celsius fahrenheit calc to Celsius to Fahrenheit Calculate Switch to the XML representation and validate the values. Add UI Elements . Table 1. String attributes allow to translate the application at a later point. <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World.4.

Make sure that your code is the same as listed below.xml" and open the Android editor via a double-click. Make sure there are two radio buttons by deleting or adding radio buttons to the group. The result should look like the following and the corresponding XML is listed below. From the Palette section Form Widgets. they just specify via an additional attribute which text type can be used. . Drag this onto the layout to create a text input field. The number of radio buttons added to the radio button group depends on your version of Eclipse. drag a Button object onto the layout. from the “Palette” view. select Text Fields and locate “Plain Text”.Select "res/layout/main. Select Delete on the popup menu to remove the text object. For changing the postion and grouping elements you can use the outline view. All object types in the section "Text Fields” derive from the class "EditText". Now select the Palette section “Form Widgets” and drag a “RadioGroup” object onto the layout. Please note that the "Palette" view changes frequently so your view might be a bit different. Hello!” in the layout. Right-click on the text object “Hello World. The following shows a screenshot of the Palette view from which you can drag and drop new UI elements into your layout. This editor allows you to create the UI via drag and drop or via the XML source code. You can switch between both representations via the tabs at the bottom of the editor. Then.

select Properties-> Text and delete the content. <?xml version="1. Most of the properties can also be changed via the right mouse menu.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <EditText android:layout_height="wrap_content" android:id="@+id/editText1" android:layout_width="match_parent" android:text="EditText"></EditText> <RadioGroup android:layout_height="wrap_content" android:id="@+id/radioGroup1" android:layout_width="match_parent"> <RadioButton android:text="RadioButton" android:layout_width="wrap_content" android:id="@+id/radio0" android:layout_height="wrap_content" android:checked="true"></RadioButton> <RadioButton android:text="RadioButton" android:layout_width="wrap_content" android:id="@+id/radio1" android:layout_height="wrap_content"></RadioButton> </RadioGroup> <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> </LinearLayout> 5. Select the EditText field.android.5. right mouse click on it.xml" and verify that your XML looks like the following.Switch to "main.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas. . Edit UI properties If you select a UI element you can change its properties via the properties view. This means no text will be initially shown in the text field.

Assign the "celsius" string attribute to your "text" property of the first radio button and "fahrenheit" to the second. .

.

<?xml version="1. Switch to the "main.” from the popup menu.android.From now on I assume you are able to use the properties menu on the UI elements.. Select “Color” and then “myColor” in the list. Set the "Input type" property to "numberSigned" and "numberDecimal" on your EditText. then select “Properties”/”Background. Assign "calc" to the text property of your button and assign "myClickHandler" to the "onClick" property.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.. Set the property "Checked" to true for the first RadioButton.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/myColor"> <EditText android:layout_height="wrap_content" android:id="@+id/editText1" android:layout_width="match_parent" android:inputType="numberDecimal|numberSigned"></EditText> <RadioGroup android:layout_height="wrap_content" android:id="@+id/radioGroup1" android:layout_width="match_parent"> <RadioButton android:layout_width="wrap_content" android:id="@+id/radio0" android:layout_height="wrap_content" android:text="@string/celsius" android:checked="true"></RadioButton> <RadioButton android:layout_width="wrap_content" android:id="@+id/radio1" android:layout_height="wrap_content" android:text="@string/fahrenheit"></RadioButton> </RadioGroup> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/calc" android:onClick="myClickHandler"></Button> </LinearLayout> .xml" tab and verify that the XML is correctly maintained. Right-click on the view in Graphical Layout mode.

layout. celsiusButton.isChecked()) { text.android.LENGTH_LONG). android.temperature. import import import import import import android.makeText(this.valueOf(convertCelsiusToFahrenheit(inputValue))).app.show().getText().radio0).id.setChecked(false).EditText. .Toast. } else { text.main).valueOf(convertFahrenheitToCelsius(inputValue))).java" to the following. Toast.id.os.setChecked(true). return.setChecked(true). android. if (celsiusButton.Bundle. public class Convert extends Activity { private EditText text.editText1).id. fahrenheitButton.widget.getId()) { case R.radio1). RadioButton fahrenheitButton = (RadioButton) findViewById(R.5. Code your application Change your code in "Convert.View. celsiusButton.view.id.vogella.getText().setText(String . android.setChecked(false).widget.setText(String . "Please enter a valid number". Note that the "myClickHandler" will be called based on the "On Click" property of your button.onCreate(savedInstanceState). } float inputValue = Float. package de. android.length() == 0) { Toast. android.Activity.RadioButton.button1: RadioButton celsiusButton = (RadioButton) findViewById(R. fahrenheitButton. if (text.toString()).parseFloat(text.6. @Override public void onCreate(Bundle savedInstanceState) { super. } // This method is called at button click because we assigned the name to the // "On Click property" of the button public void myClickHandler(View view) { switch (view. text = (EditText) findViewById(R. setContentView(R.widget.

the emulator starts up very slow. .32) * 5 / 9). right click on it. Start Project To start the Android Application. } } 5. Run-As-> Android Application Be patient. } // Converts to fahrenheit private float convertCelsiusToFahrenheit(float celsius) { return ((celsius * 9) / 5) + 32.7. You should get the following result. } } // Converts to celsius private float convertFahrenheitToCelsius(float fahrenheit) { return ((fahrenheit .} break. select your project.

8. select your conversion and press the button. Using the home menu If you press the Home button you can also select your application.Type in a number. The result should be displayed and the other option should get selected. . 5.

.

The method onCreateContextMenu() is called every time a context menu is activated as the . You can register here a menu via your code or use a XML menu resources which you inflate via a "MenuInflator". If you want to influence the menu later you have to use the method onPrepareOptionsMenu().6. You get a MenuInflator via your activity with the method getMenuInflator(). Menus To use menus Android provides two ways. The second option to display a menu is to use the context menu for a UI widget (view). A context menu is activated if the user "long presses" the view.1. onCreateContextMenu() is only called once. The option menu of your activity is filled in the method onCreateOptionsMenu() of your activity. A context menu for a view is registered via the method registerForContextMenu(view). First is the option menu which can be opened via the menu button. Menus 6.

com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Preferences"></Button> <Button android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Change Preferences"></Button> </LinearLayout> 6.xml" to the following: <?xml version="1. Create a project "de. Project This chapter will demonstrate how to create and evaluate a option menu.android.xml" and press the button "Finish".2. etc. . right click on it and select New -> Other -> Android -> "Android XML File". Select the option "Menu". 6. Add a menu XML resource Menus can be defined via XML files.vogella. enter as File "menu.3.context menu is discarded after its usage. how to define preferences and how to navigate between activities via an intent . Select your project. "EditText" provides context options to select text.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas. Change the UI in the file "/res/layout/main.android.preferences" with the activity "HelloPreferences". The Android platform may also add options to your view. e.g.

We will have only one entry. . Maintain the following value. This defines the entries in your menu.Press Add and select "Item".

*/ @Override public void onCreate(Bundle savedInstanceState) { super. inflater.menu. public class HelloPreferences extends Activity { /** Called when the activity is first created.Activity.os.widget. } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(). } .MenuItem. setContentView(R. android.layout. The behavior in "onOptionsItemSelected" is currently hard-coded to show a Toast and will soon call the preference settings. android.Menu. import import import import import import android.inflate(R.vogella.onCreate(savedInstanceState).Bundle. android. return true.app.view.Toast. android.android.MenuInflater.Change your class "HelloPreferences" to the following.view.preferences. package de. In case you want to disable or hide menu items you can use the method "onPrepareOptionsMenu" which is called every time the menu is called.menu. android.view. menu).main). The OnCreateOptionsMenu method is used to create the menu.

1. Toast. Intents allow you to start Activities from other Activities. If you select the menu entry you should see a small info message. "Just a test". Preferences are stored as key values.makeText(this.show().@Override public boolean onOptionsItemSelected(MenuItem item) { Toast. } } Run your application and press "Menu" on the emulator. The two "Preference" buttons are not yet active. 7.LENGTH_SHORT). We will use them in the next chapter. return true. Overview Preferences allow you to save data for your application. . Your menu should be displayed. Preferences and Intents 7.

Press Add. .xml" this time of type "Preference". Preference values can also be stored as a XML resource.vogella. Using preferences We will continue using the example project "de. Create another Android XML File "preferences.preferences" from the last chapter.2.7. add a category and add two preferences "EditTextPreferences" to this category : "User" and "Password".android.

import android.xml". package de.To allow the user to enter the preference value you can define a Activity with extends PreferenceActivity. Create the class "Preferences" which will load the "preference.preference. import android.Bundle. public class Preferences extends PreferenceActivity { . This activity can load a preference definition resources via the method addPreferencesFromResource().os.preferences.vogella.android.PreferenceActivity.

preferences).xml" file. Select "AndroidManifest. . */ @Override public void onCreate(Bundle savedInstanceState) { super. Add the activity "Preferences". addPreferencesFromResource(R.onCreate(savedInstanceState).xml" and the tab "Application"./** Called when the activity is first created.xml. } } To make this class available as an activity for Android you need to register it in your "AndroidManifest.

vogella.preference.SharedPreferences.Intent.PreferenceManager. import import import import import import import import android. android. .MenuInflater. android.app.SharedPreferences.The first button will show the current values of the preferences via a Toast and the second button will revert the maintained user name to demonstrate how you could change the preferences via code.Menu. android. android.view. android. android.content.android.Editor.view.content. android.content.os.Activity. package de.preferences.Bundle.

buffer. Toast. // Initialize preferences preferences = PreferenceManager.makeText(HelloPreferences.view. Button buttonChangePreferences = (Button) findViewById(R.onCreate(savedInstanceState).setOnClickListener(new OnClickListener() { public void onClick(View v) { String username = preferences.append(username.makeText( HelloPreferences.widget. /** Called when the activity is first created. // A toast is a view containing a quick little message for the // user.edit(). for (int i = username.View.charAt(i)). setContentView(R.Button.layout.import import import import import android. android. */ @Override public void onCreate(Bundle savedInstanceState) { super. "n/a").id. public class HelloPreferences extends Activity { SharedPreferences preferences.view.length() . "n/a"). } edit.OnClickListener. i--) { buffer. i >= 0.Button01). android. buttonChangePreferences.show(). // We will just revert the current user name and save again StringBuffer buffer = new StringBuffer().View. android. "n/a").".Toast.setOnClickListener(new OnClickListener() { public void onClick(View v) { Editor edit = preferences. String username = preferences. Button button = (Button) findViewById(R. "You entered user: " + username + " and password: " + password.putString("username".LENGTH_LONG). String password = preferences. } }). "Reverted string sequence of user name.Button02). } .1.getString("username".this.getString("password".view.MenuItem. button.LENGTH_LONG).toString()). We give a little feedback Toast.commit(). android.getDefaultSharedPreferences(this).main).widget. Toast.show(). Toast.id.this.getString("username". edit.

inflate(R.menu. Preferences.menu. @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater().this. The saved values should be displayed in a small message windows (Toast) if you press your first button.class). inflater.LENGTH_LONG). return true. } 7.3.show(). Run Run your application. } return true. To see the current values of the preferences we define a button and use the class "PreferenceManager" to get the sharedPreferences.preferences: // Launch Preference activity Intent i = new Intent(HelloPreferences.this. startActivity(i).makeText(HelloPreferences. You should be able to enter your user settings then press the back hardware button to return to your main activity.". break. Even though we currently have only one option in our menu we use a switch to be ready for several new menu entries. menu). } } We will update the method onOptionsItemSelected() to open the activity "Preferences" once you select the option menu. } // This method is called once the menu is selected @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item. If you press the second button the username should be reversed.id. "Here you can enter your user credentials. Toast.getItemId()) { // We have only one menu option case R.}). // Some feedback to the user Toast. . Press the "menu" hardware button and then select your menu item "Preferences".

This modal dialog gets the focus until the user closes it. Maintain the following layout for "main.xml".0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas. In this chapter we will use the class "AlertDialog".com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> .vogella. You should always open a dialog from the class onCreateDialog(int) as the Android system manages the dialog in this case for you. This method is automatically called by Android if you call showDialog(int).android.android.8. <?xml version="1. Dialogs via the AlertDialog We have already used a "Toast" which is a small message window which does not take the focus. e. you can chain your method calls. AlertDialog is used to open a dialog from our activity.alertdialog" with the activity "ShowMyDialog".g. An instance of this class can be created by the builder pattern. Create a new Android project "de.

View.app.LENGTH_LONG). android. import import import import import import import import android. } @Override protected Dialog onCreateDialog(int id) { switch (id) { case 10: // Create out AlterDialog Builder builder = new AlertDialog. } }).setCancelable(true).AlertDialog.<Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Simple Dialog" android:onClick="openMyDialog"></Button> </LinearLayout> Change the code of your activity to the following. setContentView(R.view.setNegativeButton("No.widget. int which) { Toast. android.OnClickListener() { public void onClick(DialogInterface dialog. dialog. package de. android.alertdialog.Builder(this). public class ShowMyDialog extends Activity { /** Called when the activity is first created. builder. builder.Activity. android.app.Bundle.OnClickListener() { public void onClick(DialogInterface dialog.Builder.Dialog. } public void openMyDialog(View view) { showDialog(10).DialogInterface."Activity will continue".setMessage("This will end the activity"). } }).android. no". new DialogInterface.create().os. */ @Override public void onCreate(Bundle savedInstanceState) { super.show(). builder.vogella. android.onCreate(savedInstanceState).Toast.app.AlertDialog.setPositiveButton("I agree".makeText(getApplicationContext().this.finish().show().app. android. int which) { ShowMyDialog. builder. android. } .main).content. new DialogInterface.layout. AlertDialog dialog = builder.Toast.

This chapter will demonstrate the usage of "TableLayout". On the "TableLayout" you can define which column should take additional space via the "android:stretchColumns" attribute. If several columns should take the available space you . TableLayout 9. More on dialogs can be found on Android Dialogs standard documentation. } } If you run your application and click your button you should see your dialog. Overview In earlier chapter we have used the LinearLayout which allows you to stack widgets vertical or horizontal. This layout allows you to organize a view into a table format. LinearLayout can be nested to achieve nice effects. 9. You specify via the view group "TableRow" rows for your table.return super.onCreateDialog(id). Afterwards you put widgets into the individual rows.1.

2. which will try to word-wrap the content of the specified widgets and the attribute "android:collapseColums" to define initially hidden columns. Example Create the project "de. This way you can for example add dividers between your columns. <?xml version="1.vogella.xml" to the following.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableLayout android:layout_width="match_parent" android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:stretchColumns="1"> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tableRow1"> <EditText android:text="Field1" android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText> <EditText android:text="Field2" android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="2"></EditText> </TableRow> <View android:layout_width="wrap_content" android:id="@+id/view1" android:layout_height="4px" android:background="#FF0000"></View> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content"> <EditText android:layout_height="wrap_content" android:text="Field3" android:layout_width="wrap_content" android:id="@+id/editText3"></EditText> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Field4" android:id="@+id/editText4"></EditText> </TableRow> .android. Columns will be automatically created based on the maximum number of widgets in one row.can specify them as a comma-separated list.layout. You can specific via "android:layout_column" the column a widget should go and via "android:layout_span" how many columns a widget should take. Change "main.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android. You can also put non TableRows in a table. Similar you can use the attribute "android:shrinkColumn". Via Java you can display / hide these columns via the method setColumnVisible().table" with the activity "DemoTableLayout". 9. Per default each widgets creates a new column in the row.

import import import import import android. setContentView(R.vogella.layout. Overview ContentProvider are used to provide data from an application to another.main). . /** Called when the activity is first created. ContentProvider 10.onCreate(savedInstanceState). !layout.Bundle. android. } else { button. } public void toogleHiddenRows(View view) { // Second row has index 1 layout. } } } 10. if (layout.collapse). */ @Override public void onCreate(Bundle savedInstanceState) { super. The following example will use an existing context provider from "Contacts".view.setText("Show second column").os.widget. android. package de.id.layout.tableLayout1).app.isColumnCollapsed(1)) { button.Activity. android.id. public class DemoTableLayout extends Activity { private TableLayout layout.Button.isColumnCollapsed(1)).setColumnCollapsed(1. ContentProvider do not store the data but provide the interface for other applications to access the data. private Button button. android. layout = (TableLayout) findViewById(R.1.View.TableLayout.widget.setText("Hide second column").android.</TableLayout> <Button android:text="Hide second column" android:id="@+id/collapse" android:onClick="toogleHiddenRows" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> </LinearLayout> Change the activity "DemoTableLayout" to the following to use the button to hide the second column in the table.table. button = (Button) findViewById(R.

Create contacts on your emulator For this example we need a few maintained contacts. Select the home menu and then the menu entry "Contacts" to create contacts. Press Menu and select "New Contact".2.10. .

.As a result you should have a few new contacts.

xml should look like the following.contentprovider" with the activity "ContactsView".10.android. The resulting main. Also change the layout_height to "fill_parent".android.vogella.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/contactview" /> </LinearLayout> Access to the contact content provider require a certain permission as not all applications should have access to the contact information.xml. <?xml version="1. Delete the default text. Open the AndroidManifest.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas. and select the .3. Using the Contact Content Provider Create a new Android project "de. Rename the id of the existing TextView from the example wizard to "contactview".

android.os.vogella.DISPLAY_NAME)). and select "Uses Permission".net.Contacts.Cursor. String[] selectionArgs = null. contactView.Permissions tab. } } private Cursor getContacts() { // Run query Uri uri = ContactsContract. selection. sortOrder). selectionArgs.Data.TextView. Change the coding of the activity.Contacts.app. android. projection.append(displayName). TextView contactView = (TextView) findViewById(R. */ @Override public void onCreate(Bundle savedInstanceState) { super.database.Activity.android. Cursor cursor = getContacts(). setContentView(R. } } .id.Uri.getString(cursor .Contacts. public class ContactsView extends Activity { /** Called when the activity is first created. String[] projection = new String[] { ContactsContract. return managedQuery(uri. String sortOrder = ContactsContract. From the drop-down list select the entry "android.onCreate(savedInstanceState).CONTENT_URI. package de.ContactsContract. import import import import import import android. String selection = ContactsContract. contactView.Contacts. android.READ_CONTACTS".getColumnIndex(ContactsContract.layout.moveToNext()) { String displayName = cursor. On that tab click the "Add" button.contentprovider. android.IN_VISIBLE_GROUP + " = '" + ("1") + "'".permission.Bundle.append("\n"). ContactsContract._ID.DISPLAY_NAME }.provider.main).contactview). android.DISPLAY_NAME + " COLLATE LOCALIZED ASC".widget.Contacts. contactView. while (cursor.append("Name: ").

ScrollView ScrollViews can be used to contain one view that might be to big to fit on one screen. If the view is to big the ScrollView will display a scroll bar to scroll the context.View. Create an android project "de.onCreate(savedInstanceState).os.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true"> <LinearLayout android:id="@+id/LinearLayout01" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="This is a header" android:textAppearance="?android:attr/textAppearanceLarge" android:paddingLeft="8dip" android:paddingRight="8dip" android:paddingTop="8dip"></TextView> <TextView android:text="@+id/TextView02" android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1. Of course this view can be a layout which can then contain other elements.scrollview. Create the following layout and class.vogella. public class ScrollView extends Activity { /** Called when the activity is first created. .Bundle. android.android.android. Please see the ListView Tutorial for details. 11.android.vogella.scrollview" with the activity "ScrollView". android.app.0"></Button> <Button android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Cancel" android:layout_weight="1. android.view.main). import import import import android. setContentView(R.widget.layout.0"></Button> </LinearLayout> </LinearLayout> </ScrollView> package de.Typically you would display such data in a ListView .TextView.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.0"></TextView> <LinearLayout android:id="@+id/LinearLayout02" android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit" android:layout_weight="1. <?xml version="1.Activity. */ @Override public void onCreate(Bundle savedInstanceState) { super.

id. DDMS . for (int i=0.de ". .TextView02). } view. } } The attribute "android:fillViewport="true"" ensures that the the scrollview is set to the full screen even if the elements are smaller then one screen and the "layout_weight" tell the android system that these elements should be extended. Open it to see the possible options. String s="".TextView view = (TextView) findViewById(R. i++) { s += "vogella.1.Dalvik Debug Monitor Server Eclipse provides a perspective for interacting with your device and program. DDMS perspective and important views 12. i < 100. 12.setText(s). This perspective includes the following views which can also be used independently and allows to place calls and send SMS to the device. It also allow to set the current geo position and to perform a performance trace of your application.

LogCat View You can see the log (including System.2.out.print() statements) via the LogCat view. File explorer The file explorer allows to see the files on the android simulator. 13.12.3. Shell . 12.

Uninstall an application via adb You can uninstall an android application via the shell. Start the shell via the following command "adb shell". Use "telnet localhost 5554" to conntect to your simulated device. switch to your "android-sdk" installation directory into the folder "tools". Android Debugging Bridge . Switch the the data/app directory (cd /data/app) and simply delete your android application. .2. The application data is stored in the directory "/data/data/package_of_your_app". If you have several devices running you can issue commands to one individuel device. 13. For example to change the power settings of your phone.3. use the command "quit" or "exit". rm. Emulator Console via telnet Alternatively to adb you can also use telnet to connect to the device. etc. To exit the console session. etc.g. e.13. set your current geocodes. to receive an sms and to get an incoming call make the following. // Assume the gesture file exists on your Android device adb pull /sdcard/gestures ~/test // Now copy it back adb push ~/test/gesture /sdcard/gestures2 This will connect you to your device and give you Linux command line access to the underlying file system. ls.Shell You can access your Android emulator also via the console. mkdir. e. # Lists all devices adb devices #Result List of devices attached emulator-5554 attached emulator-5555 attached # Issue a command to a specific device adb -s emulator-5554 shell 13.g. Open a shell. This allows you to simulate certain things. incoming call. adb shell You can also copy file from and to your device via the following commands. change the network "stability".1.

Select in the settings Applications > Development. 15. To select your phone. For details please see Developing on a Device . select "Manual" selection and select your device. Deploy your application on a real device Turn on "USB Debugging" on your device in the settings. Please note that the Android version you are developing for must be the installed version on your phone. Thank you . You also need to install the driver for your mobile phone. then enable USB debugging. select the "Run Configurations".# connects to device telnet localhost 5554 # set the power level power status full power status charging # make a call to the device gsm call 012041293123 # send a sms to the device sms send 12345 Will be home soon # set the geo location geo fix 48 51 For more information on the emulator console please see Emulator Console manual 14.

 .

&-:9147 ./.9. 7.3..07.3//70.250390!.947 .0/947.90 88098.4894/0130.:08..7034394903/74/5. 3.9.90901443/70.9 708.-09003-49938-.3/902094/0988098    %41....38897:.88098.!708838 %884:/.0841938 %03/74/$.3-0:80/9489470.-43 904075.791.3/& 8 394.8490 4:.439..7941908.75943970894:80907.079...343909....389.08898/.943898.9147290/70.3..8 ..9..7003 470.9:70/..33/41/..054707800.70.9:70   0708.947897:..3.... %01443/08.4:.98 0  89738.

.4:9.

3 2  .2.

08 0  14789738.90.70.90.3/.997-:908 3/74/.  70.997-:9081477084:7.484:94.

...99010708.0.4734:7..997-:908.4/0  $00.47.3-0:80/34:7&/013943.4478 %080 .84:7.

:08...

20.3/..3/57088// $00.:0   .8903.3/039072447 .890.9447.8973 2.

..9075439  %.3/..9090.:0 9408:8 94.997-:908..07843 03.3/07  $9..4/3:91  7084:7.70309 .49497.943.9090.997-:908 $973.:08       2.90 2.20 .70309 .943 .08  89733.08:8 1..079.9490705708039.20040447/ 43..  '.:..38./.55.-0 $973997-:908 ..3/07 2. //.9.84901443$973.

20.9:7043.55*3.07907.20%02507.8973  89733.

202447.8973  .4473.

.3/07..3/072.447  89733..202.

20.08:89408:8.8973  89733.

7030994.70309.201.8973  89733.

20..:.90.8973  89733....

8973 .

08       //&020398 .7084:7.

$00.9708.

4:9..

9%090/8./4:-0 .3/7.8. %80/947 ..9090&./4-:99438-/009347..389../4-:994374:5/0503/8434:7..88/9%09 90:89850.43909094-0.01742.943472/098 /7..8890/-04  .9 %03 174290 !.909.3:80904:930.70038494190!.20.9084:7.900904390545:5 203:947024.990!.4/08908.9 0447/ 04 390.98439490..4:9 $00.580 .//943.0.099080...0174290..0.4:9 %03:2-07417.-9/1107039   #9 ...029-0.9439490.4:.//0/94907.4:9 !0./7.08:709070.943%090/8 /07.3390548943 .3//74547..0990.943 472/098 .07843 41.099080.90./474:5 4-0..90 !.3 2.0909094-0. #..70.3.909950.3//74530 &00203983944:7.990-4994241900/947 47..99508390 80.1.3%09 7.3-0:80/  4800.0990 .90935:910/ 4-0.70.4:994. .997-:90.3/74:5300203984:.3/90.. -09003-49705708039..-8.:99434-0.4/0 4:.0 8:709..9438.0990./4-:994389490 74:5  74290!.3081706:039844:7 .94:7..3/4503903/74/0/947.484:94.3/4.990!.8034909.0  %01443848.70947.//37.4:9  %0708:984:/440901443..2./4-:99438.9439490 ..0 800.3//7.47708543/38890/-04 .

942.4:9238.3 2.94:74480901443       2.4/3:91  30.7.07843 03. $9.3/74/995.0719.3/.

.

02.8 .3/74/ .42.8.

.5.

708.

3/74/..5*.4:9*097.3/74/  .3/74/.943.439039 .3/74// /.7039  .4:9*091*5..7039  /9%09.3/74/.3/74/47039..4:9*/91*5.079.

3/74/909/9%09.7039 .*5.0/9%09   .3/74/.4:9*/92.9.

3/74/.3/74// /./474:5.4:9*097./9%09  #.5*.439039 .

3/74/./4:9943    .3/74/909#.3/74/.3/74// /.7039   #.*5.4:9*/97./474:5   .439039 .5*.7.9.4:9*/92./4:9943.

0/97:0.0./4     .7.5*.3/74/.439039 .3/74/.4:9*097.

3/74// /.#.3/74/./4:9943./4:9943   #.4:9*/97.439039 .3/74/909#./4:9943    .5*.

439039.3/74/./4    .5*.7.4:9*097.

#./4:9943  .

/474:5  :9943.3/74/909:9943.3/74// /.#.

5*.4:9*/97.3/74/.4:9*097.-:9943   .3/74/.5*.439039 .439039.

:9943 .

3.439 800.4:9        /9&574507908 14:800..3..990/9%0910/ 79 24:80.30/..&0020394:.3098574507908.3834909-0 39...90574507908.84339090910/  .7.3//009090.84-0..30.907924:80203: $00.0 4894190 574507908.9..439039 %820.9!74507908 %09.

/4-:9943.997-:90944:79095745079419017897.08:88973.  88390.70309949080.43/  .3/ 1.

  .

4390.3/07949043.88:204:./4:9943 883.8832.70.037.5..9 !74507908 .7423443.-094:8090574507908203:4390&0020398 $0990 57450790.3/3:2-070.0/9497:0147901789#....5745079 $099035:9950 5745079943:2-07$30/..434:7/9%09  #9 ..3/.9490909574507941 4:7-:9943.4:924/0 903800.2.

0719.07843 03.9908..39.74:3/  174290545:5203: $00.3/74/995.4:9238.3 29.4770. .92.9 447 .-.3/.94902.7.30/       2.3/903 2447 39089   $9.4/3:91  30.

.

8 .3/74/ .8.02.42.

5..

708.

079.943.7039  ..7039 .4:9*/91*5.3/74/.3/74/-..3/74/.4:9*091*5..3/74/47039.3/74/  .447..74:3/.

3/74// /.439039 .5*.4:9*097.3/74/.2447  /9%09.

3:2-07$30/.4:9*/92.3/74/35:9%503:2-070.9.7039 .2.3/74/.*5.0/9%09   .

/474:5.4:9*097./9%09  #.5*.3/74// /.3/74/.439039 .

439039    .5*.4:9*/97.9./4:9943./474:5   .7039   #.7.3/74/.3/74// /.4:9*/92.*5.3/74/.

5*./4  .3/74/9098973.7.3/74/.4:9*097.439039    .

3/74/.0/97:0..0.08:8 .

5*.3/74// /.#.439039    .3/74/./4:9943   #.4:9*/97./4:9943.

3/74/.7.439039    .4:9*097./4 .3/74/9098973.5*.

1.70309.

/4:9943  .#.

/474:5  :9943.3/74// /.#.

4:9*/97.439039 .3/74/.3/74/.5*.4:9*097.-:9943 .5*.439039   .3/74/9098973.

3/07....2.   ..3/74/43.

:9943 .

30.4:9 .7.

3/74/ ..40.55.3/74/ /09 #.94901443 4909.079 .4:9 2.55 .90    8:507 4370..90 :3/08.89  5:-.8843..9.0 '0 25479.0/389. .3/74/ 902507./4:9943 25479.90    809439039'0 # .       4/04:7.0$9.0/-...0/389.3.3    909 /9%09 13/'0/ # / 0/9%09    <   ...3/74/ ..077/0  5:-.0/0 .304:7.3/74/ 48 :3/0 25479.3/74/ /09 %4.9 25479.90/9%09909    .9  57.80/4390 3.3/07-0 ..4/0343.943 ..9902.3/74/ /09 /9%09 25479..9:70  25479.5745079414:7-:9943       5.3..9..4/4370.90 8.0790903/8.0$9.

.

8830/90 3...%82094/8.:800.-0.9-:9943..209490  .0/.

.

07908:8%4.3/07 '0..70309:9943 8090./ 3:2-07        %4.7804.70309:9943 8090.0/ 97:0     <080     909 809%09 $973       .:0 1 .70309:9943 #.0/ 97:0  .0 09/    .89 2.:0      ..70309%408:8 35:9'../4:99431./4:9943.935:9'..4/2.0/ 1.0/ 1.8003907.08:8:9943 80.57450794190-:9943  5:-./4:9943  13/'0/ # / 7..0    89. ./4     #.43.:0 1 .0/      909 809%09 $973       .70309 35:9'..:0 4.43..80      1.0%09 98 !0./4:9943  13/'0/ # / 7.08:8:9943 8090.9 909 09%09 94$973     1 .08:8:9943 8090.08:8:9943 #. 3.80# / -:9943    #.80      .9 5./4     1 909 09%09 039       %4.079.:0      1.89 %*  84      709:73    <     14.

              <      <   < < -70. .

.

70309   709:73 1.079894.43.08:8 57.079.43.9.9014..70309   .91.70309%408:8 14.

  < .

.

08:8   709:73 .9.70309 14.0798941.9..43.9014.07908:8%4.08:8  .43.70309 57.

.79!740.943 800.0784 4:84:/09901443708:9  ..94:75740.9 %489.94305..   <      $9.9039 9002:.439 #:3 8 3/74/ 55.9 79.94789.79903/74/55.798:5.

94:7.90/    &8390420203: 14:5708890420-:99434:.84800.%503.94:7..3..0/ .3/9049074594384:/09800.3/5708890-:9943 %0708:984:/-0/85.3:2-07 800.55.43.07843.943  .

.

9074:.43909203:147..99902094/0903:31.4:31..399431:03..9.4:7.203:894:8090.947.03:31.90 5943803: 414:7.90/190:80743570880890.0/0.0 %0 2094/4370. 4:7...8 78989045943203:..0  ..3-045030/.090203:.. 90203:-:9943 %045943203:414:7.904390903: 843..08.../0894.&/09 .43/4594394/85.902094/708907474390903: .07920.3708907070.  03:8   03:8 %4:80203:83/74/574..9.947  4370.43909203:147.9.90..43909203:8....9.70 5943803:  %080..4/047:80..03:31.947 4:09..890 ..203:.43909203:8.904390903: 8.0  .9810/3902094/ 4370.9.0/43.9 4:..90/.0 14:. 203:7084:7..087089070/.0 94:80902094/43!705.

70..339039 70.43909203:8/8.914722.90.3/0./08.9909 09...9.45943203: 494/0130 57010703.90...:.    !740.3/74/ 57010703..40.908.08.7/0/.3/4943.0 %03/74/5.84..08990.0 0  /9%09574. ..9 %8.5907/0243897..3090&390 10..90494.90.5740.190798:8.9.9 /0 .90-09003..08 .4390945943894800.904!7010703.//459438944:7 .

708.

4:9..

07843 03.4:9238.3/74/995.4/3:91  30.7.2.3 294901443      2.

.

02.8.42.3/74/ .8 .

.5.

708.

4:9*091*5.943.7039  .3/74// /.4:9*/91*5.3/74/47039.3/74/..3/74/  ..7039  :9943.079.3/74/..

439039   .5*.5*.3/74/.3/74/909$4 !7010703.:9943  .439039.08.4:9*/97.4:9*097.3/74/.

:9943  :9943.3/74// /.

4:9*097.5*.:9943  .3/74/.5*.3/74/.30 !7010703.3/74/909.439039   .08.439039.4:9*/97.

:9943 .

439.80 203: 2.3-0/0130/.3/800.9 79.90  907 3/74/ 3/74/0 $00..9904594303: 03907.203:7084:7.30.94:75740.7.4:9        //.3/5708890-:994338  .0 03:8.108 $00...

 !7088//.9902 .39..:0 %8/013089003970834:7 203: 0.0434300397  .3901443..3/800.

.89  5:-..89.8804!7010703.0809938 3.70 5943803:..3/74/ .47343 59438902$00.3/74/ .4/0/ 9484.0894901443 %0 370..3/74/ .0 03:902 25479.9.3/74/ .0/0 .9090203: %0-0.40.9  .90 5943803:2094/ 8:80/94.9.%4.08  25479. .0 03:31.9 25479.70.080903/8..3/8443..90/8.0/0.304:7.804:.0/       5.3:80902094/43!705.-047/0 203:90284:.9057010703..907 25479.3/74/ 48 :3/0 25479.3/74/ 57010703..3/74/ /09 %4.:77039.7/ .55 ...0792090 203:8.0 03: 25479.8804!7010703.8.3994/8. ..

.981789. .0/0390.70.9.90/  .

077/0  5:-.0/389.3.-440.4/4370.907 31.90    8:507 4370.34370.0$9.077/0  5:-.   .3   <    ...90 # 203: 203: 203:    709:7397:0  < .90731.4:9 2.90 8.907    31.3.0$9.9070903:31.0/389..90    809439039'0 # .90 5943803: 03:203:    03:31.90 :3/08.

90/ 03:902902    %4.7034909.908  .-440.08.44:9489.80.:08  390398.55.7089470/.990203:03974:84:/800.9.44:948.9.0 !7010703.   .89 2.90817424907.1474:7.943 !7010703.08.89 %*$ #% 84    709:7397:0  < <      #:34:7.0/.9.0 0:80902390309.82.943.947 4:7203:84:/-0/85.9.5907   !7010703..79.3142088.077/0  5:-.3/390398    .0   %094!7010703.3/5708803:439002:..07.0/ 1 4:800.0-:99438.55.08..0%09 98 :89....343 59438902$00.9089  %4.

0   !7088// .4393:0:83900...349073/74/0 57010703..7084:7.08 29892041950!7010703.3/74/ 57010703.3/!.84-089470/.:08.9047.08174290.//9457010703.90.89 .089498.8847/  .3/.3.9/0 .0. ..  &8357010703.40.0 70.9047 &807.08/9%09!7010703.8.08 0.//.2505740...5907  !7010703.

9.88!7010703.08  25479.902094/ ..3/74/ 57010703..3/74/ 57010703.3/74/ 48 :3/0 25479.9..9.990903/8 !7010703.080903/8!7010703..9 %8.9 ...9.:04:.0 2       5.0 70.0.40..3/0130..490:80794039079057010703.9..08.0/0 ./.0 !7010703.88!7010703.0.0.08../90 57010703. .0..57010703.08742#084:7.34.  %4.9090.9.9  5:-.0/0139437084:7.4.//!7010703.

          <   .

70.0/0390. .9..90/  .981789.

9.9!7010703...3.4/4370...943 // 90.098.08742#084:7.31089 2.9..91473/74/4:300/94708907934:7 3/74/.08  .31089 210 $00.0$9..3/909.90 :3/08.0$9..3.0 # 2 57010703.90 8.3.08  <      %42.93/74/.077/0 5:-.90  .90  8:507 4370.-55.88.0/389..-0..//!7010703.8.0/389..  .

.3/74/ 48 :3/0 25479.%4.39.%01789-:99438490.3/74/ 57010703...08....08 /947 25479.907 .:77039..:08419057010703.3/74/ .0.07 25479.3/74/ .2094/0243897.3/74/ .3/74/ 57010703.0 03: 25479.70/!7010703.4/0       5.439039 $..3/74/ .4:/.55 .40.43/ -:994370.3/74/ .9.89.3.0 03:31..439039 $.08.70/!7010703.079902.08  25479.3/9080.9 25479.9044:.0 !7010703.3/74/ .0/0 .08 25479.439039 39039 25479.3090 57010703.30/:8073.

70/!7010703.3/74/ .3/74/ .0 03:902 25479.890307 25479.08   .3/74/ .0 '0 3.25479.0 '0 25479..9  $.9..0857010703.3/74/ /09 %4.080903/8.8804!7010703.3/74/ /09 :9943 25479.89  5:-.

70.90/  . .981789.9.0/0390..

0$9.90 8.0$9..4:9 2.0/389.90 :3/08.3.   .077/0  5:-.3    :9943-:9943 :9943 13/'0/ # / :9943     ...90    8:507 4370.4/4370.3.0/389.90    809439039'0 # .

.

39. '0.4/43.:9$.057010703.08   57010703.20 57010703.70/!7010703.0.3.890307 30 3.      $973:8073.20 3.08 !7010703.08 98     -:9943 809 3.08 09$973 :8073.07 0901.890307     5:-..

08 09$973 5.      $9735..8847/ 57010703.8847/ 3.

     /9470/957010703.      %4. '0.89 %*  84      <   <     :9943-:9943.08 :9943  13/'0/ # / :9943     -:9943.4/43.20 57010703.8847/  %4.3/5..8847/         5.08 98        4:039070/:807  :8073.08 09$973 :8073.30!7010703.890307 30 3.20 3.0%09        04!7010703.30!7010703.890307     5:-.08 809 3.08 0/9      $973:8073..20 .89 2.

      ..

.

20  -:1107 94$973      0/9 .:77039:8073.20 .3     $973:1107-:110730$973:1107      147 39:8073.07990.20 .3/8.79       <     0/9 5:9$973 :8073.0:8970...0..5503/ :8073.4229      .20 039           -:1107 .

.

014790     .94.0.439.898.6:.33. 9902088..

.

08 98        #0.041 :8073.89 2.990100/-.20         %4.0.0790/8973806:03.     %4..0%09 04!7010703.:807 0.89 %*  84     < .

0434304594334:7203:0 :80.90902094/43 59438902$00.34370..   <   <  <    0:5/.0 4:800..:77039.08         ./14780.88!7010703.90 # 203: 203: 203:    709:7397:0  <   .080/0130.90 5943803: 03:203:    03:31.70/!7010703.89..:77039.07.907    31.0843.9070903:31.9.0394:0.907 31.9!7010703.3.90731.99045943203: .:084190 57010703.077/0  5:-.-440.90/ 94450390.07940990 8.94-070.30203:039708 %480090.3/:8090.0..-:9943.

.

90/ 03:902902    89.090203:8800.90/   .077/0  5:-.0/43.343 59438902$00..-440. 902 09902/    .%82094/8.

.

.80# / 57010703.08    .0.043430203:45943   ..

.

9      .08 98  !7010703.0.9..9    390393039039 04!7010703.08 .!7010703..9.88     89.79..:3.

.

.3/903800.9.03/48 %4.55.7/.82..89 %*  84     -70.89 2...70/039.0/3.89 14:570884:71789-:9943 14:570889080.:0884:/-0/85.. 2088.70 -:994394709:73944:72.0%09 04!7010703.08 4:84:/-0.94:7203:902 !7010703.9490:807    %4..0/.-094039074:7:8078099389035708890-.8        %4.3039074:7:807 .    <   709:7397:0  <        #:3 #:34:7.2084:/-070.$420100/-.43/-:994390 :8073..0780/  .70-:9943.08 98       0704:.9 %08..3.7/.943 !708890203:.

2088.4 39 .3-0../:80/.4 39  70.8  4:84:/.34:72094/ .4174290.3/74/ ..801474: %82094/8..884370.3901443.90/-90-:/075.9.8903/74/88902 2.303/74/5740.90.48.090 14.0.04198.7./.90.3.....:8 398.3.417424:7.84503.4398.88079.3.4 0.4/3:91  30..40.89...39.079/.../4083499. .4:91472.  .99073 0  4:.4990.48:80/944503.59070:8090.0890/.4 .88.82. /.:8:3990:807.9.%4.:942.9 %824/.8.70..48089  3389.3/74/995./..07843 03.0/-3/74/1 4:..4 079.40989014.3 2      2..9/0 ..4:9238.9 $4..70.90079.03/4.9.84.

.

8.8 .02.42.3/74/ .

5..

708.

7039  .943.3/74/.7039  ..3/74/  .4:9*091*5...3/74/47039.3/74/.4:9*/91*5.079.

 :9943.3/74// /.

5*.439039   .3/74/.4   .:9943  .4.4:9*/97.5*.3/74/43.439039.4:9*097.3/74/909$4 $250.3/74/.4503.

:9943 .

4 :/07 25479.3090.55 ..3/74/ 48 :3/0 25479.9.4  25479.55 .55 079.89  5:-.0 '0 25479.40903/8.3/74/ .4:9     ..3/74/ .9 25479.0 25479..079/.40...439039 .88$4.4 25479.30.9.0/0 .4/0414:7.3/74/ ..9. .3/74/ .3/74/ .3/74/ .7.9  .439071.4 25479.55 079.3/74/ .3/74/ /09 %4.994901443      5.

.9.0/0390.90/  ..981789.70.

80  .90.90 :3/08.90    809439039'0 # .44370.4 39/  89.4 '0.3.90    8:507 4370.4/4503.90 8.0/389.3    <   5:-.077/0  57490.4:9 2..0    84.90/.4    <    ...3.0$9..4/4370.   . /  .0$9..077/0  5:-.0/389.

.

4 39.439071.3.70.4-:/07 .0/...9.0 %803/90..4/.  %4.9..0 3.9  -:/07 809..439071.  $4.890307  5:-.90  /.0:9943 .4 39.9 .890307  5:-.4 :/07 98  -:/07 809088.9..0%09 0955.4 84  < ..0.0 3.94343909 .4393:0 %4.0:9943 4 34 30 .4/43.4/43.439071.70.4 :/07-:/0730079..4 98 138  < <  -:/07 8090. .89 2.904:9907.89 %*  84  < <  079.0/.700 30 . .-0 97:0  -:/07 809!489.439071.

4:9..4889.3-030890/94.7/84:5:9/098394903/.484:9489.. 30.-0.943   %./098.4:9  %8.7//4..-0#47481474:79..07.90.943.090.1.//943.9090:8..709:738:507 4370.484:9447. 4747439.90 ..85.03.3-014:3/433/74/.0:80/9030...7.7.9.997-:90 180..9 4:850..-0./:..5907 /0243897.3/..-01472.4:7-:99434:84:/8004:7/.3/0130.48.074:5 %.0..748  390%.0.0..3/..041%.-0 1907.59070.4:9    .04: ..079.30.00110.707..3/74/89709.4:9.90..4:9.55..4:2384:/9..0394.4   47043/.4:94:..4:238.98 %8.4 /  <  <    14:7:34:7.4:23884:/9.0 30.-0..07.-085.:2039.

4390394190850.4. 805.10//098 .8.3/74/.5804:2894/013039..7.3850.3/85.590...4:238 '...3/74/8734:23 .74:.979447/ 7..422.//03..997-:90 .997-:90..1902.3/90.90/89 $2.3:8090.4: ..

:90.1.7./078 -090034:7.9/0 .31470.0  4:.4:23..902094/8094:23'8-0  4:238-0./0984:/9.4:2390.-0 %8....4:238.4:2339074 4:.3/74/995.3/74/ .9.30.9.4:9*.4:9*85.4:238    .40.4/3:91  30. .2:23:2-0741/098343074  !07/01..3/74/..-0.3.845:9343%..250 70./0984:/4.-0#483.80/43902.:942. ./09080.07843 03.4:9238.70..70..90/-.4:.34 2.4:9 9.-0990.3/74/.3 294901443       2.///.90905740..250.3.302.9..4:9  ..4:238.9024%.908./098.3/.3850.

.

02.8 .3/74/ .42.8.

.5.

708.

3/74/47039.*5.3/74/.943.9.3/74// /.-0.7039  %.7039  .4:9*/92..7039   .079.3/74/.4:9*/91*5.3/74/..4:9*091*5.4:9.3/74/  ..

*5.9.4:9*097.-0#4.-0.4:9*097.7039    .439039 .5*.4:9 .5*.3/74/.9.3/74// /.439039   .4:238   %.3/74/89709.3/74/.4:9*/92.3/74/.

9.-0#4    /9%09.3/74/9090/ .3/74// /.

5*.439039 .439039.3/74/.4:9*/97.4:9*097.3/74/.0/9%09     .5*.

/9%09    /9%09.3/74/9090/ .3/74// /.

4:9*/97.5*.439039 .439039     .4:9*.4:9*097.4:23.3/74/.0/9%09     .3/74/.3/74/.5*.

/9%09   .

5*.3/74// /.%.3/74/.439039 .-0#4   '0.4:9*/97.

74:3/ ..3/74/-..3/74/.4:9*095 .0    .

-0#4.'0   %.3/74// /.

3/74/.3/74// /.4:9*097.439039    .-0#4 .9.4:9*097.5*.3/74/9090/     .439039    /9%09.439039 .3/74/.5*.5*.4:9*/97.439039 .4:9*/97.5*.3/74/.3/74/.

0/9%09.

4:9*097.439039     .3/74/.3/74// /.5*./9%09    /9%09.4:9*/97.439039 .3/74/9090/     .3/74/.5*.

0/9%09.

/9%09   .

-0#4  .%.

 .

43/.3/74/909/080.-0.3/74// /.4:23 .%.4:9  :9943.

4:9*/97.5*..4.3/74/.9440//03#48 .439039.4:9*097.439039   .5*.580   .3/74/.3/74/43.

:9943 .

..-0       5.9 25479.4:233909.3/74/ /09 :9943 25479.9.9  57..3/74/ .3/74/ 48 :3/0 25479.3/74/ .40. ..90:9943-:9943   .4:9.9024%.-0  25479.90%.7.-0.4:9 9.4:9      ..4:9  5:-.43/ .4:99490144394:8090-:994394/09080.30.0/0 .-0.4:90903/8.0 '0 25479.9.55 .88024%.3/74/ .9...4:9  57.3090.-0.-0.3/74/ /09 %.

.90/  .70.981789..9.0/0390.

0/389.4/4370.0$9.580    <   5:-.3    .077/0  5:-..3...4:9 %.0/389.90    809439039'0 # .4:9    -:9943 :9943 13/'0/ # / .3..4/9440//03#48 '0.90    8:507 4370.0$9.   .4:9 2.90 8.4.0    .-0.90 :3/08.-0.4:9 13/'0/ # / 9.

.

3.580/    1 .55..43/74.4:23    <080    -:9943 809%09 /080.250:80./071742439.9..34907 439039!74.01474907./07    .0 439039!74.4:9 84:234.43/./09039071.  %014430.-:9574.30893.$0./0/.55..943894..94394..1742.4:9 84:234.4:9 8094:234.4:23    <  < <       439039!74../07.9.43909574.43/.9.07.98  .83/0   .580/  .08890/.580/      -:9943 809%09 $480./07/4 3498947090/.70:80/94574.

439.98   !708803:.2500300/..9894.990420203:..439.98 $00.70.90.90439.90..30/.9  .439.102..3/800.39.  70.947 47980..98434:702:.3/90390 203:0397439.

439.708:94:84:/...98  .0.1030. 8.

0 0090 90/01./07990.9/0 .7039  %0708:932.:9909 84.3090..3/74/ ..3 284:/440901443       2.439039574.9./07 70.303/74/5740...9 439.3/74/995.9439039!74.07843 03. .7.4:9238.90.7/94.2090/41900893%09'01742900.250.9.4/3:91  30.98'0  #03.40..   &8390439.439.4:9*09941*5.

.

8 .42.8.02.3/74/ .

5..

708.

7039   .4:9*091*5.3/74/  ..079.4:9*091*5.7039  %09'0.3/74// /...943.7039 .3/74/.3/74/.3/74/.4:9*/91*5.4:9*/91*5.3/74/.7039  .3/74/47039.

.9.439..0.

 .

.350728843..55..439.8349.7.931472.079..439039574..3/800.990 .439.31089 2 ./07706:70.943  503903/74/.9438 84:/.30..0889490...4:9      .0889490..0.9.

-  39.9900397.9.3/74/ /09 %09'0  5:-.88439.80 :7847 25479.3/74/ ./07 439.9.3/800...9       5.!072884389.3/74/ 309 &7 25479.9&808!0728843 74290 /745 /4389800.3/74/ 574.9....98'00903/8.3/74/ .-.90//-:9943 . ..439039574.9..4/34190.99./07  25479.-.40.3/74/ 50728843 #* %%$  .984397.9 25479.3090.3/74/ /.9 25479.9  .55 .0/0 ..3/74/ 48 :3/0 25479..

70..90/  . .981789.9.0/0390.

5503/ ...20     .439. $!*     ..5503/ /85.3.9 .9.20     .984397.9'0 .98    ...0%409      $973/85...4:9 2.90 :3/08...:7847 09$973 ..4/4370.439.90    8:507 4370.20.0$9..439.439.:784709439.0     :7847.3.9'0 ..:7847 24..90 8.   ..439.0/389.3    %09'0.98     0 .9.90    809439039'0 # .077/0  5:-.9'0 .0$9.90:784709439.9'0 %09'0  13/'0/ # / .:7847      094:233/0 439.5503/ 3    <  <   57.0/389..

.

94330$973( 439...94378      8479 7/07   <  <     .9 439..9 439.9 439.98  %%*&#   $973(5740.984397..943  800...98 *'$*# &!              $973(800....984397.984397..943 800.984397.3.0/":07 :7 5740....9 439..984397.98 $!*<   $973800..943 439.9 439.943783:   $9738479 7/07439.98 *      439.98 $!*      % $    709:732.#:36:07   &7:7439.

4:9.808009089'0%:947.4:78098 .147 /09.349070020398  70.74'08..4/3:91  $.40.7003 190 .../.3430.74'0  70.9/0 .%5.09.74'0 $.43909  1.9$.929-094-9419434308.3.7490..74.07843 03. .0..439.89'0 !0.74-..9.90901443.74'0/85.90.3903.8   $.0894-90$.3/.8:.3/74/ 8.3.88      2.8.3-0:80/94.3/74/5740.0990.3/74/995.4:4://85...3-0..439.4:9.7948.9.74'0238.

.

3/74/ .42.02.8.8 .

5..

708.

3/74/.3/74/47039.4:9*/91*5.7039.079..3/74/.4:9.7039  .4:9*091*5.3/74/1'0547997:0  30..3/74/  .943.7..3/74// /.

4:9  .30.3/74/.3/74/.4:9*097.5*.7.079..3/74// /.943.4:9*/91*5.439039  %09'0..3/74/47039.7039 .

4:9*097.3/74/909550.439039 .3/74/.3.4:9*/97.439039.5*.%09'0  .7.0./07 .3/74/.0.3/74/909%88.997.3/74/.5*.

//3#9/5 .3/74/5.909550.7.3.70 .0.//3019/5.3/74/5.//3%45/5.3/74/5.

%09'0  %09'0.3/74/909 /.

3/74// /.%09'0  .

439039 .5*.4:9*091*5.7039.4:9*09 .%09'0 .3/74/.3/74/.4:9*/97.3/74/.

7.3/74// /.%09'0    30.4:9.

4:9*/97.5*.3/74/.4:9*097.4:9  .3/74// /.5*.30.439039.439039   :9943.3/74/.7.

5*.4:9*/97.3/74/.3/74/909$:-29.439039 .4:9*097.3/74/.:9943  .5*.4:9*09 .3/74/.439039.

:9943   :9943.3/74// /.

4:9*09 .5*.3.5*.4:9*/97.3/74/909.3/74/.439039 .:9943  .4:9*097.0.439039.3/74/.3/74/.

:9943  .

4:9 .7.30.

30.7.4:9 .

74.3/74/ .3/74/ .0/0 .74'0         5.9 .$.0  25479..55 ..9.3/74/ /09 %09'0  5:-.3/74/ 48 :3/0 25479.9 25479..88$.40.9.3/74/ 8.0 '0 25479. ..74'00903/8.

0/0390..981789.70.90/  . .9.

90  809439039'0 # .90 8.077/0 5:-.4/4370.0$9.0/389.3.90 :3/08.  .3..4:9 2.90  8:507 4370..3  .0$9..0/389.

079034308.. /0 < .3/.7082.74.84.0 %09'0 13/'0/ # / %09'0   $9738 147 39     8 ./08.39..01473907.84-0:80/ 3/0503/039.9394:7/0..9.3.3/5747.0-:43947$07.40.0 809%09 8  < <    %0.3/803/$$9490/0.0414:7.08.943  .2  503994800 905488-0459438 %8507850.%09'0.3/74/1'0547997:0038:7089.:/08901443.031900020398.4:9*099090 ...9.8.3/74/889029.997-:90.097.5071472.03.3/945071472..99080002039884:/-00903/0/    $507850.580574.07 .49480990 .0 9.3.3/25479.08   $ ..990908.0.55.:7703904548943..3/90.7003.0.0.0880994901: 8.9..507850..48945.70030.

904.947    $0 .0    0054707 %010054707.9020398 .:/3$8902 4:9 5739 89.9'0 4:.3800904 3.3/74/82:.  4.9..4894800901084390..

9473949014/079448 $9.84..799080.0.3.90.0884:73/74/02:.43840  503.  3/74/0-:37/0 $0 4:..3/.45101742..901443 .422.943/70.947.3/944:7/0..422./-80         4:.80 89...3/74/ 8/389../-80    .944:7 ..901443..84.3.3/8       .

.

/-5:.88:2090089:70100898434:73/74//0..0 .

.7/.8/.

089:708=.

9089 .

.

 .4..459-./-5:8=.

9089.

089:70.

7/.8/..

%0.0..422.3/30.9..04:3:.943/.94:944:7/0..889470/390/70.947 .4330..0889490 :3/0731088902 0  8 72 2/7 09.55.3/.089:708     %8.

/.9.

9./.

99..3/74/..943..3:3389.0/ 88:0.9080 $9.07../- 4:.0/ 02:..3.943..../- 802:.3..9090/.850./0..0/ 02:.55  14:.3/94.0 ....0*41*4:7*.5.55.080..08.99.388:0.1.9...3/8944303/.08 #08:9 8941/0.55.947 ../0..422.087:3334:..08 ./0./-/0.422.947 .947 80        &3389.99.0       898../:0/0...

947 ..55/70./ .

9./.

079..:77039 04.094.90.423.9. &80903094.90//0.90309 9073.4/08 09.0 %8.423.9944:782:..484:94 82:..55.3/74/.3/9409..25094.94743840.422..0..2...3/6:94709  470.30903094789.4330.30905407809938414:75430 9470.3.84:809030994.3/825/00904:7.3828. ..943    2:.3938 0  3.3 3.48994.99490/0.55 ../-4:.-9 8094:7.0..0 %40990 .0901443  .43390.43840808843 :8090.

  0544:7.34:  .939080993855..4384050.850.3:.071474:7 24-05430 47/09.9..0 903094..8289490/0.-0&$/0-:3 4:.0452039 90303.0 828803/-04208443 80990044.0     %.943.078434:.943 041     47247031472.9:81: 540789.0 !0.943439002:.8034909..0 %:7343&$0-:3434:7/0..     .94:75430 800.9903/74/ ..70/0..0 540789.   803/.84300/94389./0.9 4:7/0.70.....9490/0.90/7.9438 800.9:8.800.0.3/800..07843434:75430  %4800.04531472:89-090389.9894/0.947.4330..808002:..808000.0/.0390809938 $00.0 82.990#:3431:7.489 8099054070.55.9438 0..3:.94343.0.73 2.045343.947438402.

Sign up to vote on this title
UsefulNot useful