Introduction to Android Programming – Workshop Berglind Ósk Bergsdóttir CC-BY-SA 2012
Android applications <ul><li>Open development platform written in Java
The Android SDK tools compile the code into an Android package (.apk)
The Android operating system is a multi-user Linux system ( 2.6 ) in which each application is a different user.
Each process has its own instance of the Dalvik virtual machine. </li></ul>
Android Manifest.xml <ul><li>A must for every application in its root directory
Info about version number,  min sdk version, install location
User permissions
Declare activities, services, broadcast receievers... </li><ul><li>launchMode, screenOrientation, theme: </li></ul><li>and...
UI – resources folder <ul><li>Xml layout files </li><ul><li>layout-hdpi, -mdpi, -ldpi, -land, -xlarge
LinearLayout, RelativeLayout </li></ul><li>Drawables </li><ul><li>drawable-hdpi, -mdpi, -ldpi </li></ul><li>Menus and cont...
Values </li><ul><li>strings </li></ul></ul>
UI –LinearLayout
Activity <ul><li>Typically represents one screen
Must implement  onCreate(Bundle savedInstanceState)
Needs a view (xml layout file)  setContentView(R.layout.activity_layout )
When a new activity starts, it is pushed onto the back stack </li><ul><li>&quot;last in, first out&quot; </li></ul><li>Lis...
Fragments (API level 11> = 3.0>) </li></ul>
 
Activity <ul><li>Starting an activity
Upcoming SlideShare
Loading in...5
×

Android basics

3,890

Published on

Introduction to Android workshop for Hakkavélin hackerspace in Reykjavík January 2012

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

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

No notes for slide

Android basics

  1. 1. Introduction to Android Programming – Workshop Berglind Ósk Bergsdóttir CC-BY-SA 2012
  2. 2. Android applications <ul><li>Open development platform written in Java
  3. 3. The Android SDK tools compile the code into an Android package (.apk)
  4. 4. The Android operating system is a multi-user Linux system ( 2.6 ) in which each application is a different user.
  5. 5. Each process has its own instance of the Dalvik virtual machine. </li></ul>
  6. 6. Android Manifest.xml <ul><li>A must for every application in its root directory
  7. 7. Info about version number, min sdk version, install location
  8. 8. User permissions
  9. 9. Declare activities, services, broadcast receievers... </li><ul><li>launchMode, screenOrientation, theme: </li></ul><li>android:theme=&quot;@android:style/Theme.NoTitleBar&quot; </li></ul>
  10. 10. UI – resources folder <ul><li>Xml layout files </li><ul><li>layout-hdpi, -mdpi, -ldpi, -land, -xlarge
  11. 11. LinearLayout, RelativeLayout </li></ul><li>Drawables </li><ul><li>drawable-hdpi, -mdpi, -ldpi </li></ul><li>Menus and context menus
  12. 12. Values </li><ul><li>strings </li></ul></ul>
  13. 13. UI –LinearLayout
  14. 14. Activity <ul><li>Typically represents one screen
  15. 15. Must implement onCreate(Bundle savedInstanceState)
  16. 16. Needs a view (xml layout file) setContentView(R.layout.activity_layout )
  17. 17. When a new activity starts, it is pushed onto the back stack </li><ul><li>&quot;last in, first out&quot; </li></ul><li>ListActivity
  18. 18. Fragments (API level 11> = 3.0>) </li></ul>
  19. 20. Activity <ul><li>Starting an activity
  20. 21. Getting extras </li></ul>
  21. 22. Adapters <ul><li>Populates a view with data
  22. 23. Handles user selections
  23. 24. BaseAdapter with listviews
  24. 25. http://developer.android.com/resources/tutorials/views/hello-gridview.html </li></ul>
  25. 26. Service <ul><li>Long running operation in background
  26. 27. startService();
  27. 28. bindService();
  28. 29. Runs in the main thread!! </li></ul>
  29. 30. AsyncTask <ul><li>A neat way to do heavy background thread work like talking to webservice
  30. 31. defined by 3 generic types, called Params, Progress and Result, and 4 steps, called onPreExecute, doInBackground, onProgressUpdate and onPostExecute. </li></ul>
  31. 32. Application <ul><li>Base class to maintain global application state
  32. 33. Instantiated for you when the process for your application/package is created. </li></ul>
  33. 34. Data Storage <ul><li>Shared Preferences </li><ul><li>Store private primitive data in key-value pairs. </li></ul><li>Internal Storage </li><ul><li>Store private data on the device memory. </li></ul><li>External Storage </li><ul><li>Store public data on the shared external storage. </li></ul><li>SQLite Databases </li><ul><li>Store structured data in a private database. </li></ul><li>Network Connection </li><ul><li>Store data on the web with your own network server. </li></ul></ul>
  34. 35. Shared prefs
  35. 36. Debugging <ul><li>adb (Android Debug Bridge) is a command line tool to communicate to device/emulator </li><ul><li><sdk>/platform-tools/adb logcat
  36. 37. Logcat also in Eclipse </li></ul><li>Log.d(TAG, “This is a log msg”);
  37. 38. v(verbose), d(debug), i(info), e(error), w(warning) </li><ul><li>adb logcat *:D
  38. 39. adb logcat | ~/coloredlogcat.py
  39. 40. http://jsharkey.org/blog/2009/04/22/modifying-the-android-logcat-stream-for-full-color-debugging/ </li></ul></ul>
  40. 41. <ul><ul>Let's do some coding!! </ul></ul>
  41. 42. Hello world! <ul><li>http://developer.android.com/resources/tutorials/hello-world.html
  42. 43. Remove ugly title bar on top </li><ul><li>android:theme=&quot;@android:style/Theme.NoTitleBar&quot; </li></ul><li>Add a button </li><ul><li><Button android:text=&quot;Button&quot;
  43. 44. android:id=&quot;@+id/button1&quot;
  44. 45. android:layout_width=&quot;wrap_content&quot;
  45. 46. android:layout_height=&quot;wrap_content&quot;></Button> </li></ul></ul>
  46. 47. Hello world! <ul><li>Click button to share on facebook/twitter/email </li></ul>Intent intent = new Intent(Intent. ACTION_SEND ); intent.setType( &quot;text/plain&quot; ); intent.putExtra(Intent. EXTRA_SUBJECT , &quot;email subject&quot; ); intent.putExtra(Intent. EXTRA_TEXT , &quot;must be a url to post this text to facebook&quot; ); startActivity(Intent. createChooser (intent, &quot;Share...&quot; ));
  47. 48. More tutorials <ul>http://developer.android.com/resources/tutorials/views/index.html </ul>
  48. 49. The end <ul><li>Advanced Android workshop later!
  49. 50. Slides on slideshare.net
  50. 51. [email_address]
  51. 52. @beggaboo85 </li></ul>
  1. A particular slide catching your eye?

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

×