Android basics

  • 3,781 views
Uploaded on

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

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

More in: Education , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,781
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
112
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

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