0
An android development tutorial for beginners... Ajailal.P
MOBILE OS <ul><li>Symbian </li></ul><ul><li>iPhone </li></ul><ul><li>RIM's BlackBerry </li></ul><ul><li>Window mobile </li...
WHAT IS ANDROID? <ul><li>Google    OHA (Open Handset Alliance) </li></ul><ul><ul><li>The first truly  open  and  comprehe...
WHY ANDROID <ul><li>A simple and powerful SDK </li></ul><ul><li>No licensing, distribution, or development fees </li></ul>...
ANDROID SDK FEATURE <ul><li>Network </li></ul><ul><ul><li>GSM, EDGE, and 3G networks, WiFi, Bluetooth </li></ul></ul><ul><...
ANDROID VERSIONS 1.5  Cupcake 1.6  Donut 2.0/2.1  Éclair 2.2  Froyo 2.3  Gingerbread 3.0  Honeycomb
TOOLS <ul><li>The Android Emulator  </li></ul><ul><ul><li>Implementation of the Android virtual machine  </li></ul></ul><u...
ANDROID APPLICATION ARCHITECTURE <ul><li>Views: </li></ul><ul><ul><li>Building block for user interface components. </li><...
ANDROID APPLICATION ARCHITECTURE <ul><li>Services (Background) </li></ul><ul><ul><li>Ex: Network Operation </li></ul></ul>...
VIEW <ul><li>Layout of visual interface </li></ul><ul><li>Java Code  </li></ul><ul><ul><li>Initialize  </li></ul></ul><ul>...
VIEW COMPONENT <ul><li>Widget Toolbox </li></ul><ul><ul><li>TextView, EditText,Button, Form, TimePicker… </li></ul></ul><u...
ACTIVITY <ul><li>  A single, focused thing that the user can do. Activities are like a stack. So when we call startActivit...
Activity lifecycle
USER INTERACTION EVENT  <ul><li>onKeyDown, onKeyUp </li></ul><ul><li>onTrackBallEvent </li></ul><ul><li>onTouchEvent </li>...
INTENT <ul><li>An intent is an abstract description of an operation to be performed. </li></ul><ul><ul><li>Launch an activ...
SERVICE <ul><li>Service class </li></ul><ul><ul><li>public class MyService extends Service  </li></ul></ul><ul><ul><li>pub...
WORKING IN BACKGROUND <ul><li>Services  </li></ul><ul><ul><li>NO GUI,  higher  priority than inactive Activities </li></ul...
THREADING <ul><li>What to thread? </li></ul><ul><ul><li>Network, file IO, Complex processing </li></ul></ul><ul><li>How ? ...
EXTERNAL RESOURCES <ul><li>values/ </li></ul><ul><ul><li>String, color, array, dimension, style theme </li></ul></ul><ul><...
SERVICE APP – MANIFEST.XML <ul><li>Service </li></ul><ul><li>Activity (intent-filter) </li></ul><ul><li>Permission </li></ul>
NORMAL APPLICATION – MANIFEST.XML Application Activity 1 (main) Activity 2  SDK Version Screen Support
DEBUG <ul><li>Package - android.util.Log </li></ul><ul><li>View results </li></ul><ul><ul><li>Logcat </li></ul></ul><ul><u...
DEBUG ON DEVICE <ul><li>On device </li></ul><ul><ul><li>Debug mode </li></ul></ul><ul><li>On desktop </li></ul><ul><ul><li...
INSTALL PACKAGE TO ANDROID PHONES <ul><li>Compile the apk packages in Eclipse  </li></ul><ul><ul><li>Export signed applica...
DALVIK DEBUG MONITORING SERVICE
ANDROID DEBUG BRIDGE (ADB)
 
Upcoming SlideShare
Loading in...5
×

android-tutorial-for-beginner

3,453

Published on

Published in: Technology, Art & Photos
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,453
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
329
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "android-tutorial-for-beginner"

  1. 1. An android development tutorial for beginners... Ajailal.P
  2. 2. MOBILE OS <ul><li>Symbian </li></ul><ul><li>iPhone </li></ul><ul><li>RIM's BlackBerry </li></ul><ul><li>Window mobile </li></ul><ul><li>Linux </li></ul><ul><li>Palm WebOS </li></ul><ul><li>Samsung BADA OS </li></ul><ul><li>Android </li></ul><ul><li>… . </li></ul>
  3. 3. WHAT IS ANDROID? <ul><li>Google  OHA (Open Handset Alliance) </li></ul><ul><ul><li>The first truly open and comprehensive platform for mobile devices, all of the software to run a mobile phone but without the proprietary obstacles that have hindered mobile innovation. </li></ul></ul><ul><ul><li>Linux OS kernel </li></ul></ul><ul><ul><li>Java programming </li></ul></ul><ul><ul><li>Open source libraries: SQLite, WebKit, OpenGL </li></ul></ul>
  4. 4. WHY ANDROID <ul><li>A simple and powerful SDK </li></ul><ul><li>No licensing, distribution, or development fees </li></ul><ul><li>Development over many platform </li></ul><ul><ul><li>Linux, Mac OS, windows </li></ul></ul><ul><li>Excellent documentation </li></ul><ul><li>Active developer community </li></ul>
  5. 5. ANDROID SDK FEATURE <ul><li>Network </li></ul><ul><ul><li>GSM, EDGE, and 3G networks, WiFi, Bluetooth </li></ul></ul><ul><li>Libraries </li></ul><ul><ul><li>SQLite (lightweight relational DB), WebKit layout engine coupled with chrome web browser, SSL </li></ul></ul><ul><ul><li>VGA, 2D graphics library, 3D graphics library based on OpenGL ES 2.0 specifications, and traditional smart phone layouts. </li></ul></ul><ul><li>Hardware control </li></ul><ul><ul><li>video/still cameras, touch screens, GPS, accelerometers, gyroscopes, magnetometers, proximity and pressure sensors, thermometers, accelerated 2D and 3D graphics. </li></ul></ul><ul><li>Location-based service </li></ul><ul><ul><li>map (Google API) </li></ul></ul>
  6. 6. ANDROID VERSIONS 1.5 Cupcake 1.6 Donut 2.0/2.1 Éclair 2.2 Froyo 2.3 Gingerbread 3.0 Honeycomb
  7. 7. TOOLS <ul><li>The Android Emulator </li></ul><ul><ul><li>Implementation of the Android virtual machine </li></ul></ul><ul><ul><li>Test and debug your android applications. </li></ul></ul><ul><li>Dalvik Debug Monitoring Service ( DDMS ) </li></ul><ul><ul><li>Monitor and Control the Dalvik virtual machines </li></ul></ul><ul><ul><li>Logcat (see logged msgs) </li></ul></ul><ul><li>Android Debug Bridge ( ADB ) </li></ul><ul><ul><li>Manage the state of an emulator instance or Android-powered device </li></ul></ul><ul><ul><li>Copy files, install compiled application packages, and run shell commands. </li></ul></ul><ul><li>TraceView </li></ul><ul><ul><li>Graphical analysis tool for viewing the trace logs from your Android application </li></ul></ul><ul><ul><li>Debug your application and profile its performance </li></ul></ul><ul><li>MkSDCard </li></ul><ul><ul><li>Creates an SD Card disk image </li></ul></ul>
  8. 8. ANDROID APPLICATION ARCHITECTURE <ul><li>Views: </li></ul><ul><ul><li>Building block for user interface components. </li></ul></ul><ul><li>Activities </li></ul><ul><ul><li>A single, focused thing that the user can do. </li></ul></ul><ul><ul><li>Interaction with users: creating a window to place UI </li></ul></ul>
  9. 9. ANDROID APPLICATION ARCHITECTURE <ul><li>Services (Background) </li></ul><ul><ul><li>Ex: Network Operation </li></ul></ul><ul><li>Intent </li></ul><ul><ul><li>Inter-communication among activities or services </li></ul></ul><ul><li>Resource </li></ul><ul><ul><li>Externalization of strings and graphics </li></ul></ul><ul><li>Notification </li></ul><ul><ul><li>signaling users: Light, sound, icon, dialog, notification </li></ul></ul><ul><ul><li>Ex: new message arrives </li></ul></ul><ul><li>Content Providers </li></ul><ul><ul><li>share data between applications </li></ul></ul>Intent
  10. 10. VIEW <ul><li>Layout of visual interface </li></ul><ul><li>Java Code </li></ul><ul><ul><li>Initialize </li></ul></ul><ul><ul><li>Access </li></ul></ul><ul><ul><li>TextView myTextView = (TextView)findViewById(R.id.myTextView); </li></ul></ul><?xml version=”1.0” encoding=”utf-8”?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent”> <TextView android:id=”@+id/myTextView” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”Hello World, HelloWorld” /> </LinearLayout> @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.screen); } screen.xml
  11. 11. VIEW COMPONENT <ul><li>Widget Toolbox </li></ul><ul><ul><li>TextView, EditText,Button, Form, TimePicker… </li></ul></ul><ul><ul><li>ListView </li></ul></ul><ul><ul><li>Layout </li></ul></ul><ul><ul><ul><li>To positions of controls </li></ul></ul></ul><ul><ul><ul><li>LinearLayout, Relativelayout, </li></ul></ul></ul><ul><li>Menu </li></ul><ul><ul><li>ex. Exit, Settings etc </li></ul></ul>
  12. 12. ACTIVITY <ul><li> A single, focused thing that the user can do. Activities are like a stack. So when we call startActivity(), we are telling Android &quot;put this activity on top of mine” </li></ul><ul><li>Foreground Activity: suspended when invisible </li></ul><ul><ul><li>Visual, interactive </li></ul></ul><ul><ul><li>Ex: Game, Map </li></ul></ul><ul><li>Background Service : Little interaction </li></ul><ul><ul><li>Ex: Hardware, power management </li></ul></ul><ul><li>Intermittent Activity </li></ul><ul><ul><li>Notification </li></ul></ul>
  13. 13. Activity lifecycle
  14. 14. USER INTERACTION EVENT <ul><li>onKeyDown, onKeyUp </li></ul><ul><li>onTrackBallEvent </li></ul><ul><li>onTouchEvent </li></ul>myEditText. setOnKeyListener (new OnKeyListener () { public boolean onKey (View v, int keyCode , KeyEvent event ) { if (event.getAction() == KeyEvent.ACTION_DOWN) if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { … return true; } return false; }});} registerButton. setOnClickListener (new OnClickListener() { public void onClick(View arg0) {….}}
  15. 15. INTENT <ul><li>An intent is an abstract description of an operation to be performed. </li></ul><ul><ul><li>Launch an activity </li></ul></ul><ul><ul><ul><li>Explicit </li></ul></ul></ul><ul><ul><ul><li>Implicit: Android selects the best </li></ul></ul></ul><ul><ul><ul><li>startActivity(); </li></ul></ul></ul><ul><ul><li>Subactivity: feedback </li></ul></ul><ul><ul><ul><li>Child: use intent as feedback, setResult ( before finish() ) </li></ul></ul></ul><ul><ul><ul><li>Parent: onActivityResult </li></ul></ul></ul><ul><ul><ul><li>startActivityForResult </li></ul></ul></ul><ul><ul><li>Action, data, extra parameter </li></ul></ul><ul><ul><ul><li>intent.putExtra(name, property) ; </li></ul></ul></ul>Ex: Intent intent = new Intent(MyActivity.this, MyOtherActivity.class);
  16. 16. SERVICE <ul><li>Service class </li></ul><ul><ul><li>public class MyService extends Service </li></ul></ul><ul><ul><li>public void onStart() {…} </li></ul></ul><ul><li>Manifest.xml </li></ul><ul><ul><li><service android:enabled=”true” android:name=”.MyService”></service> </li></ul></ul><ul><li>Control </li></ul><ul><ul><li>startService </li></ul></ul><ul><ul><li>stopService </li></ul></ul><ul><li>Communication </li></ul><ul><ul><li>Bind service with activity: use public method and properties </li></ul></ul><ul><ul><li>Intent </li></ul></ul>
  17. 17. WORKING IN BACKGROUND <ul><li>Services </li></ul><ul><ul><li>NO GUI, higher priority than inactive Activities </li></ul></ul><ul><ul><li>Usage: </li></ul></ul><ul><ul><ul><li>responding to events, polling for data, updating Content Providers. </li></ul></ul></ul><ul><ul><li>However, all in the main thread </li></ul></ul><ul><li>Background threads </li></ul>
  18. 18. THREADING <ul><li>What to thread? </li></ul><ul><ul><li>Network, file IO, Complex processing </li></ul></ul><ul><li>How ? </li></ul><ul><ul><li>new Thread </li></ul></ul><ul><ul><li>Synchronize threads </li></ul></ul><ul><ul><ul><li>Handler.post() </li></ul></ul></ul><ul><ul><li>UI Thread ( AsyncTask ) </li></ul></ul><ul><ul><ul><ul><li>doInBackground() </li></ul></ul></ul></ul><ul><ul><ul><ul><li>onPreExecute() </li></ul></ul></ul></ul><ul><ul><ul><ul><li>onProgressUpdate() </li></ul></ul></ul></ul><ul><ul><ul><ul><li>onCancelled() </li></ul></ul></ul></ul><ul><ul><ul><ul><li>onPostExecute() </li></ul></ul></ul></ul>
  19. 19. EXTERNAL RESOURCES <ul><li>values/ </li></ul><ul><ul><li>String, color, array, dimension, style theme </li></ul></ul><ul><li>drawables/ </li></ul><ul><ul><li>Images, icon </li></ul></ul><ul><li>layout/ </li></ul><ul><ul><li>main.xml </li></ul></ul><ul><li>Menu </li></ul><ul><ul><li>menu.xml </li></ul></ul><ul><li>There can be separate layout and drawables folders for landscape and portrait orientation. </li></ul><ul><li>There can be different layout and drawables folders for small, large and normal screen. And hdpi, mdpi, ldpi resolutions. </li></ul>
  20. 20. SERVICE APP – MANIFEST.XML <ul><li>Service </li></ul><ul><li>Activity (intent-filter) </li></ul><ul><li>Permission </li></ul>
  21. 21. NORMAL APPLICATION – MANIFEST.XML Application Activity 1 (main) Activity 2 SDK Version Screen Support
  22. 22. DEBUG <ul><li>Package - android.util.Log </li></ul><ul><li>View results </li></ul><ul><ul><li>Logcat </li></ul></ul><ul><ul><li>Eclipse IDE </li></ul></ul>
  23. 23. DEBUG ON DEVICE <ul><li>On device </li></ul><ul><ul><li>Debug mode </li></ul></ul><ul><li>On desktop </li></ul><ul><ul><li>Connect your Phone with your PC </li></ul></ul><ul><ul><li>When it asks for driver location choose </li></ul></ul><ul><ul><ul><li>For windows, android-sdk-windows-1.5_r3usb_driverx86 </li></ul></ul></ul><ul><ul><li>You'll see sth like &quot;HTC Dream Composite ADB Interface&quot; on success </li></ul></ul><ul><ul><li>(Re)Start Eclipse </li></ul></ul><ul><ul><li>Your G1 should now be listed in the DDMS-Perspective under Device </li></ul></ul>
  24. 24. INSTALL PACKAGE TO ANDROID PHONES <ul><li>Compile the apk packages in Eclipse </li></ul><ul><ul><li>Export signed application package </li></ul></ul><ul><li>adb install …apk </li></ul><ul><ul><li>Error: uninstall </li></ul></ul>
  25. 25. DALVIK DEBUG MONITORING SERVICE
  26. 26. ANDROID DEBUG BRIDGE (ADB)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×