Your SlideShare is downloading. ×
  • Like
Introduction to android
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Introduction to android


Quick start android for beginners

Quick start android for beginners

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE AddisIntroductionAndroid OverviewAndroid is a comprehensive open source platform designed for mobile devices. It is championedby Google and owned by Open Handset Alliance. The goal of the alliance is to “accelerateinnovation in mobile and offer consumers a richer, less expensive, and better mobileexperience.” Android is the vehicle to do so.  In 2005, Google buys Android, Inc. The world thinks a “gPhone” is about to come out.  In 2007, the Open Handset Alliance is announced. Android is officially open sourced.  In 2008, the Android SDK 1.0 is released. The G1 phone, manufactured by HTC and sold by the wireless carrier T-Mobile USA, follows shortly afterward.  2009 sees a proliferation of Android-based devices. New versions of the operating system are released: Cupcake (1.5), Donut (1.6), and Eclair (2.0 and 2.1). More than 20 devices run Android.  In 2010, Android is second only to Blackberry as the best-selling smart phone platform. Froyo (Android 2.2) is released and so are more than 60 devices that run it.Android VersionsLike any software, Android is improved over time, which is reflected in its version numbers.However, the relationship between different version numbers can be confusing. Table 1-1 helpsexplain that Android version API level Nickname Android 1.0 1 Android 1.0 Android 1.1 2 Android 1.1 Android 1.5 3 Cupcake Android 1.6 4 Donut Android 2.0,2.01,2.1 5 ,6,7 Eclair Android 2.2 8 Froyo (frozen yogurt) Android 2.3,2.3.3 9,10 Gingerbread Android 3.0 ,3.1,3.2 11,12,13 Honeycomb Android 4.0,4.03 14,15 Ice cream Sandwich Android 4.1,4.2 16,17 Jelly Bean
  • 2. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE AddisHow many Devices“A big day for Android... 500 million devices activated globally, and over 1.3 million addedevery single day," said Hugo Bara, Androids director of product management, in a Google+post. Its not clear how many devices are replacing older ones, though. September 12, 2012Why Android as developersSecurityLinux is a highly secure system, having been tried and tested through some very harshenvironments over the decades. Android heavily relies on Linux for security. All Androidapplications run as separate Linux processes with permissions set by the Linux system. Assuch, Android passes many security concerns to the underlying Linux system.FeaturesLinux comes with a lot of very useful features. Android leverages many of them, such as supportfor memory management, power management, and networking.Application FrameworkContains application framework which provides numerous services to help you, the appdeveloper, get your job done. This is the best-documented and most extensively covered part ofthe platform because it is this layer that empowers developers to get creative and bring fantasticapplications to the market.Native LibrariesThe native libraries are C/C++ libraries, often taken from the open source community in order toprovide necessary services to the Android application layer. Among others, they include:  Webkit A fast web-rendering engine used by Safari, Chrome, and other browsers  SQLite A full-featured SQL database  Apache Harmony An open source implementation of Java  OpenGL 3D graphics libraries  OpenSSL The secure locket layer
  • 3. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE AddisSetting up your IDEQuick configuration with Android BundleThe Android SDK provides you the API libraries and developer tools necessary to build, test,and debug apps for Android.If youre a new Android developer, we recommend you download the ADT Bundle to quicklystart developing apps. It includes the essential Android SDK components and a version of theEclipse IDE with built-in ADT (Android Developer Tools) to streamline your Android appdevelopment. With a single download, the ADT Bundle includes everything you need to begindeveloping apps:  Eclipse + ADT plugin  Android SDK Tools  Android Platform-tools  The latest Android platform  The latest Android system image for the emulatorHow to configure 1. Download ADT Bundle for your operating system from 2. Unpack the ZIP file (named adt-bundle-<os_platform>.zip) and save it to an appropriate location, such as a "Development" directory in your home directory. 3. Open the adt-bundle-<os_platform>/eclipse/ directory and launch eclipse.
  • 4. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE AddisUSE AN EXISTING IDEIf you already have an IDE you want to use for Android app development, setting up a new SDKrequires that you download the SDK Tools, then select additional Android SDK packages toinstall (such as the Android platform and system image). If youll be using an existing version ofEclipse, then you can add the ADT plugin to it.How to configure 1. Download android SDK from 2. Start Eclipse, then select Help→Install New Software 3. In the Available Software dialog, click Add. 4. In the Add Site dialog that appears, enter a name for the remote site (for example, 5. “Android Plugin”) in the “Name” field. 6. In the “Location” field, enter this URL: 7. Click OK. Back in the Available Software view, you should now see “Developer Tools” added 8. To the list. Select the checkbox next to Developer Tools, which will automatically 9. Select the nested tools Android DDMS and Android Development Tools. Click Next. 10. In the resulting Install Details dialog, the Android DDMS and Android Development 11. Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish. 12. Restart Eclipse.
  • 5. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE AddisCode PracticeDeclaring Activity 1. In Eclipse click File->New->Android Application Project 2. Specify all required infrmation as shown below 3. Click Next antil you reached activity creation step, and specify activity information as shown below
  • 6. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE Addis 4.Click finish, your project will be created as shown below.
  • 7. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE Addis 4. Open up the manifest file from the Package Explorer, and then click on the AndroidManifest.xml tab at the bottom to display the code that the IDE has produced. Within the <activity> element, find the following attributes: android:name=".MainActivity" android:label="@string/app_name" 5. Edit the code so that it matches the following snippet: <activity android:name=".MainActivity" android:label="Welcome to Android Introduction" android:screenOrientation="portrait"> ... </activity> 6. To run your application you need to create android virtual device , to do so click “Android Virtual Device Manager” from task bar as shown in the figure below. Android Virtual Device Manager
  • 8. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE Addis 7. You will be presented with virtual device manager as shown below 8. Click New and create new emulator and start . 9. Now close all the dialog except the emulator , and return to your Eclipse IDE 10. To run your application click Run ->RunStarting a new activity with an intent object 1. Now from package explorer go to res->layout and open main.xml 2. Next to </TextView> Insert button as shown below <Button android:id="@+id/callButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Call Log" /> 3. Save and close 4. From package explorer got src and open and put the following method at the end inside the class void startCallButton () {
  • 9. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE Addis Intent myIntent = new Intent(); myIntent.setAction(Intent.ACTION_CALL_BUTTON); startActivity(myIntent); 5. Insert button click event listener code show bellow in to onCreate() method next setContentView() Button cButton=(Button)findViewById(; cButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub startCallButton(); } }); 6. Save the project and run,and click the button 7. If this generates an error message, it may be that the correct libraries have not been imported. To use intents we have to import the relevant library, which can be done with import android.content.Intent; however its easy to get Eclipse to import any missing libraries simply by pressing Shift + Ctrl + O.
  • 10. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE AddisSwitching between activitiesOften we will want to activate one activity from within another. Although this is not a difficult task, itwill require more setting up than the previous two recipes as it will need two activities to be declared inthe Manifest, a new Class to serve as our second activity, and a button along with a click listener toperform the switch. 1. Create a new activity in the same location as the original activity subclass to do so: Right Click on your project->click New->click other You will be presented with the following dialog box. 2. Select Android Activity and click next ->next until you reach new activity dialog box and Activity Name- MySubActivity Layout Name – mysub And leave everything as it is and click finish.
  • 11. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE Addis 3. Next, we must add a button that the user can click on to switch activities. This is set up through the main.xml file which resides in the res/layout folder in the Package Explorer. 4. Open the main.xml file and click on the XML tab at the bottom so that the code can be edited. 5. Add the following <Button> element just after the call button from previous example y: <Button android:text="click to switch activities" android:id="@+id/main_activity_button" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> 6. Now open the original Java activity class,. 7. Add the following code to the onCreate() method after the setContentView(R. layout.main); statement, making sure to replace the package and class parameters in the setClassName() call with your own, as they will most likely be different: Button switchButton = (Button) findViewById(; switchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); String packageName = "com.example.mysimpleapp "; String className = "com.example.mysimpleapp.MySubActivity"; intent.setClassName(packageName, className); startActivity(intent); } }); 8. Run the application on a device or emulator. Clicking on the button will now start the sub activity.Passing Data from one activity to another 1. Create a new project with these project name PassDataActivity. Leave everything else as it is by default and click finish. 2. Open activity_main.xml and put EditText and Button as shown below. <EditText android:id="@+id/messageText" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > <requestFocus /> </EditText>
  • 12. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE Addis <Button android:id="@+id/sendButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Send" /> 3. In the package explorer open and add the following code to the onCreate() method after the setContentView(R. layout.main); Button mSendButton=(Button)findViewById(; mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub EditText MessageText=(EditText)findViewById(; Intent intent= new Intent(); intent.setClassName("com.example.passdataactivity","com.example.passdataactivi ty.SecondActivity"); intent.putExtra("com_example_passdataactivity_id", mMessageText.getText().toString()); startActivity(intent); } }); 4. Now time to create our second activity, add new activity and name it SecondActivity. Leave everything as it and click finish. 5. From package explorer Open and add the following code to the onCreate() method after the setContentView(R. layout.main); String msg=getIntent().getExtras().getString("com_example_passdataactivity_id "); EditText msgView=new EditText(this); msgView.setText(msg); setContentView(msgView); 6. Run the application on a device or an emulator.
  • 13. Introduction To Android Bantyder Bahru GDG-AddisMarch 30, 2013 ICE AddisResources • ORielly Learning Android, Marko Gargenta • APress Beginning Android 4,Grant Allen • PACKT,Android 3.0 Application Development Cookbook, Kyle Merrifield Mew •