Geekcamp Android

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

2 comments

Comments 1 - 2 of 2 previous next Post a comment

Post a comment
Embed Video
Edit your comment Cancel

Favorites, Groups & Events

Geekcamp Android - Presentation Transcript

  1. Android Development GeekCamp Singapore 22 nd August 2009 Leong Hean Hong (CC) BY-SA Some rights preserved.
  2. About
    • Usernames: hongster, ahhong
    • DOB: 490204800 (GMT +8)
    • Work: LAMP | Android | iPhone
    • Interest: Python, Rubik Cube, Number Theory, Web Technologies
    • Groups: SG PHP User Group, KL Google Technology User Group
  3. Content
    • Intro
    • Development Tools
    • Setup
    • 4 Component Types
    • Views
    • Intents
    • Demo
  4. Intro
    • Android != OS “ Android™ delivers a complete set of software for mobile devices: an operating system, middleware and key mobile applications. ”
    • Android Architecture ( http://bit.ly/s73P2 )
    • Dalvik_VM != JVM
      • Designed and written by Dan Bornstein with contributions from other Google engineers
      • Bytecode on which it operates is not Java bytecode.
  5. Development Tools
    • Android 1.5 SDK
    • Optional, recommended
      • Eclipse (Java or RCP version recommended)
      • Android Development Tools ( ADT ) eclipse plugin (http s ://dl-ssl.google.com/android/eclipse/)
  6. Setup
    • Download and unzip Android SDK.
    • Install Eclipse.
    • Install ADT.
    • Set SDK path in Eclipse preference section.
    • Create Android Virtual Device ( AVD ).
    • RTFM and start coding.
    • Reference: http://bit.ly/3T24gE
  7. Linux Tips
    • Don’t use package manger, download Eclipse and unzip it.
    • Use Sun Java ( “requires plug-in org.eclipse.wst.sse.ui” error )
    • If installed Eclipse using root , update using root .
    • Run <android-sdk>/tools/ddms once, before installing ADT. (solved in ADT 0.9.1 http://bit.ly/15FdZt )
  8. Application Components
    • Activity
      • Presents a visual UI for user to interact with.
      • Similar to UIViewController.
    • Service
      • No visual UI, run in background for an indefinite period of time.
      • Similar to daemon.
    • Broadcast Receiver
      • Does nothing but receive and react to broadcast announcements (E.g. Timezone changed, battery low, ...).
    • Content Provider
      • Makes a specific set of the application's data available to other applications. (E.g. Wrapper for data in file system or DB)
  9.  
  10. Android Project Folders
    • src/
      • Source code.
    • Android 1.5/
      • Library you will use.
    • gen/
      • AIDL (Android Interface Definition Language), auto generated.
    • asset/
      • Save data as asset when you need to read raw bytes.
  11. Android Project Files
    • res/ (application resources access through R class)
      • drawable/ (bitmap files)
      • layout/ (design Views , similar to HTML)
      • values/ (predefined values, can be referenced in application)
    • AndroidManifest.xml
      • Similar to iPhone’s Info.plist.
      • Contains application settings (E.g. Intent filters, permission, activities, …)
    • default.properties
      • Contains project settings such as build target.
  12. /res/layout/main.xml
    • Layout for main activity.
    • Contains:
      • LinearLayout for arranging subviews
      • TextView for displaying text
      • Button
    • An ID (helloButton) is assigned to the button. Can be referenced through R.id.helloButton .
    • Button text is defined in /res/values/string.xml .
  13. Add Button (main.xml) <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:orientation=&quot;vertical&quot; android:gravity=&quot;center&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;> <TextView android:layout_width=&quot; wrap_content &quot; android:layout_height=&quot;wrap_content&quot; android:text=&quot;@string/hello&quot; /> <Button android:id=&quot;@+id/helloButton&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:text=&quot;@string/hello_button&quot; /> </LinearLayout>
  14. Launch Image Gallery private static final int REQUEST_PICK_IMAGE = 1; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button)findViewById(R.id.helloButton); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent pickImage = new Intent(Intent.ACTION_PICK); pickImage.setType(&quot;image/*&quot;); startActivityForResult(pickImage, REQUEST_PICK_IMAGE); } }); }
  15. Intent
    • Abstract description of an action to be preformed.
    • Intent messaging is a facility for late run-time binding between components in the same or different applications.
    • Activity , Service , BroadcastReceiver are activated through Intent .
    • Intent Resolution
  16. New Activity
    • Create a new Activity called PhotoViewer
    • Create a Layout to display the photo (photo_viewer.xml)
    • Use a ImageView to display photo
    • GoodByeWorld launch PhotoViewer by sending it an Intent
    • The Intent contains the URI of the selected image
    • ImageView load image from the URI
  17. /res/layout/photo_viewer.xml
    • Layout for the PhotoViewer Activity
    • Contains an ImageView for displaying image
    • The ImageView is given an ID ( photoView )
  18. photo_viewer.xml <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:orientation=&quot;vertical&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;> < ImageView android:id=&quot;@+id/photoView&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot; /> </LinearLayout>
  19. PhotoViewer.java protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.photo_viewer ); ImageView photoView = (ImageView)findViewById( R.id.photoView ); photoView.setImageURI( getIntent().getData() ); }
  20. AndroidManifest.xml <application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;> <activity android:name=&quot;.GoodByeWorld&quot; android:label=&quot;@string/app_name&quot;> <intent-filter> <action android:name=&quot;android.intent.action.MAIN&quot; /> <category android:name=&quot;android.intent.category.LAUNCHER&quot; /> </intent-filter> </activity> <activity android:name=&quot;.PhotoViewer&quot;></activity> </application>
  21. Create Menu private static final int MENU_RED = Menu.FIRST; private static final int MENU_GREEN = Menu.FIRST + 1; private static final int MENU_BLUE = Menu.FIRST + 2; private static final int MENU_RAND = Menu.FIRST + 3; public boolean onCreateOptionsMenu (Menu menu) { super.onCreateOptionsMenu(menu); menu.add(Menu.NONE, MENU_RED, Menu.NONE, &quot;Filter Red&quot;); menu.add(Menu.NONE, MENU_GREEN, Menu.NONE, &quot;Filter Green&quot;); menu.add(Menu.NONE, MENU_BLUE, Menu.NONE, &quot;Filter Blue&quot;); menu.add(Menu.NONE, MENU_RAND, Menu.NONE, &quot;Random Filter&quot;); return true; }
  22. Response to Menu Selection public boolean onMenuItemSelected (int featureId, MenuItem item) { super.onMenuItemSelected(featureId, item); switch(item.getItemId()) { case MENU_RED: photoView. setColorFilter (redFilter()); break; case MENU_GREEN: photoView. setColorFilter (greenFilter()); break; case MENU_BLUE: photoView. setColorFilter (blueFilter()); break; case MENU_RAND: photoView. setColorFilter (randFilter()); break; } return true; }
  23. Color Filter Matrix
  24. ColorMatrixColorFilter private ColorMatrixColorFilter redFilter() { return new ColorMatrixColorFilter(new float[] { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 }); }
  25. Q & A Any question?

+ Hean Hong LeongHean Hong Leong, 3 months ago

custom

543 views, 0 favs, 3 embeds more stats

Introduction to Android. These slides are presented more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 543
    • 519 on SlideShare
    • 24 from embeds
  • Comments 2
  • Favorites 0
  • Downloads 27
Most viewed embeds
  • 21 views on http://gtugkl.blogspot.com
  • 2 views on http://blog.gtugkl.org
  • 1 views on http://www.blogger.com

more

All embeds
  • 21 views on http://gtugkl.blogspot.com
  • 2 views on http://blog.gtugkl.org
  • 1 views on http://www.blogger.com

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories