A Noob’s Guide to Android Application Development By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  BarCamp Singapore 3 28/2/2009
Who am I? Student from NUS – Bioengineering  Interest in mobile platforms C programming sellAndroid != false (Google can pay me if they want =D); Intent intent = new Intent(BarCamp3.this, ShareInterest.class); By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
What is in this presentation? Why Android? How to Get Started? “ Deep” Dive How to Publish? Resources Available Q&A
Why Android? I am cool! By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Why Android? Open Market Place Instant publishing and feedback! You can create “ANYTHING” By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Why Android? Background applications Finally useful apps fBook notification! Contextual based applications … .. yourapp.apk By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Why Android? Develop on ANY platform FREE (no need to buy!) Windows Linux Mac By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Why Android? Not just on mobile! Netbooks MIDs Desktop Phone?? By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
How to get started? Fix me! By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
How to get started? Things to install (developer.android.com) Java Developers Kit (JDK ) Eclipse or any other IDE Android SDK  Android Developers Tool (ADT) By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
“ Deep” Dive By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
“ Deep” Dive Applications in Java Import Java libraries Import Android libraries GUI Widgets Animation By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Starting an Application Activity Lifecyle void onCreate void onStart() void onRestart() void onResume()  void onPause() void onStop() void onDestroy()  By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  “ Deep” Dive
Applications Fundamentals Activities (Application != Activity) What the user see on the screen 1 app can have multiple activities  Draw using xml and call by  Activity.setContentView()  Services Runs in background indefinitely  E.g. music playback even when activity is stopped Broadcast receivers does nothing but receive and react to broadcast announcements  E.g. SMS receiver Content providers Data that can be accessed by the application  SQlite or any file system By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  “ Deep” Dive
Applications Fundamentals Intent Intent object holds the content of the message E.g. intent is used when you want to start a new activity and intent will carry the name of the activity and content needed to be pass through Android Manifest Declaring the application's components e.g. libraries  Identifying any permissions the application expects to be granted Mostly auto generated by ADT in Eclipse By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  “ Deep” Dive
Example: PathFinder@SG extending ListActivity Package: com.pathfinder.sg CategoriesListActivity.java PlacesListActivity.java Services: MyPositionService .java (to obtain location from GPS, cell tower) Content Provider: xml file in /res/raw containing location data By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  “ Deep” Dive
Set view using ListAdapter  (since this is ListActivity) Starting GPS/ntw service Staring the Application: OnCreate  Android logging class for logcat on DDMS (debugging) By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  “ Deep” Dive
Moving to Another Activity Using Intent By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  Initialize intent variable: Intent(packageContext,  Class)  Start activity Add extended content to be passed through intent: putExtra(String name, value) Bonus point: If you intend to end current activity and back to previous, use finish() instead “ Deep” Dive
Make sure you stop services that is not needed upon exit! i.e. GPS service will otherwise continue to run in background By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  Remember to consider other parts of the lifecycle “ Deep” Dive
By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  Android Manifest User permission needed  Declare activities within the application “ Deep” Dive
Applications Debugging DDMS in Eclipse using ADB By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  “ Deep” Dive
How to Publish? By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
How to Publish? Export and signing your app Export your application from Eclipse project Application will be exported as .apk Sign myapp.apk with Keytool and Jarsigner (within JDK) Take note on validity date of private key during keygen – recommend at least “10000 days” http://developer.android.com/guide/publishing/app-signing.html By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  Suggested commands $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000 $ jarsigner -verbose -keystore my-release-key.keystore my_application.apk alias_name
How to Publish? Publishing on Android Market Sign up as an Android developer at developer.android.com USD$25 sign up fee Upload and monitor!  By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
How to Publish? Market Business Policies Payment - 70% developer 30% telco Currently paid apps in UK and US No obscene materials (porn etc) 24 hour return policy Dispute resolution handled by developer and user directly Google holds the right to remove application if found of violation http://www.codeandroid.org/forum/?wpforumaction=viewtopic&t=1.0 By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Resources By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Resources Android Resources developer.android.com Open Source Codes for Android Application code.google.com/hosting/ Online Tutorials www.anddev.org Developers Group Google Group (Android Beginner, Developer, Discuss) Codeandroid.org  (Singapore Android User Group) By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Resources GUI XML Tool for Android DroidDraw   Hacking/Flashing Android ROMs XDA Developers List of all applications on Android Market http://www.cyrket.com/   By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
Q&A By: Chua Zi Yong Singapore Android User Group www.codeandroid.org  ??

A Noob’S Guide To Android Application Development

  • 1.
    A Noob’s Guideto Android Application Development By: Chua Zi Yong Singapore Android User Group www.codeandroid.org BarCamp Singapore 3 28/2/2009
  • 2.
    Who am I?Student from NUS – Bioengineering Interest in mobile platforms C programming sellAndroid != false (Google can pay me if they want =D); Intent intent = new Intent(BarCamp3.this, ShareInterest.class); By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 3.
    What is inthis presentation? Why Android? How to Get Started? “ Deep” Dive How to Publish? Resources Available Q&A
  • 4.
    Why Android? Iam cool! By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 5.
    Why Android? OpenMarket Place Instant publishing and feedback! You can create “ANYTHING” By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 6.
    Why Android? Backgroundapplications Finally useful apps fBook notification! Contextual based applications … .. yourapp.apk By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 7.
    Why Android? Developon ANY platform FREE (no need to buy!) Windows Linux Mac By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 8.
    Why Android? Notjust on mobile! Netbooks MIDs Desktop Phone?? By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 9.
    How to getstarted? Fix me! By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 10.
    How to getstarted? Things to install (developer.android.com) Java Developers Kit (JDK ) Eclipse or any other IDE Android SDK Android Developers Tool (ADT) By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 11.
    “ Deep” DiveBy: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 12.
    “ Deep” DiveApplications in Java Import Java libraries Import Android libraries GUI Widgets Animation By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 13.
    Starting an ApplicationActivity Lifecyle void onCreate void onStart() void onRestart() void onResume()  void onPause() void onStop() void onDestroy() By: Chua Zi Yong Singapore Android User Group www.codeandroid.org “ Deep” Dive
  • 14.
    Applications Fundamentals Activities(Application != Activity) What the user see on the screen 1 app can have multiple activities Draw using xml and call by Activity.setContentView() Services Runs in background indefinitely E.g. music playback even when activity is stopped Broadcast receivers does nothing but receive and react to broadcast announcements E.g. SMS receiver Content providers Data that can be accessed by the application SQlite or any file system By: Chua Zi Yong Singapore Android User Group www.codeandroid.org “ Deep” Dive
  • 15.
    Applications Fundamentals IntentIntent object holds the content of the message E.g. intent is used when you want to start a new activity and intent will carry the name of the activity and content needed to be pass through Android Manifest Declaring the application's components e.g. libraries Identifying any permissions the application expects to be granted Mostly auto generated by ADT in Eclipse By: Chua Zi Yong Singapore Android User Group www.codeandroid.org “ Deep” Dive
  • 16.
    Example: PathFinder@SG extendingListActivity Package: com.pathfinder.sg CategoriesListActivity.java PlacesListActivity.java Services: MyPositionService .java (to obtain location from GPS, cell tower) Content Provider: xml file in /res/raw containing location data By: Chua Zi Yong Singapore Android User Group www.codeandroid.org “ Deep” Dive
  • 17.
    Set view usingListAdapter (since this is ListActivity) Starting GPS/ntw service Staring the Application: OnCreate Android logging class for logcat on DDMS (debugging) By: Chua Zi Yong Singapore Android User Group www.codeandroid.org “ Deep” Dive
  • 18.
    Moving to AnotherActivity Using Intent By: Chua Zi Yong Singapore Android User Group www.codeandroid.org Initialize intent variable: Intent(packageContext,  Class) Start activity Add extended content to be passed through intent: putExtra(String name, value) Bonus point: If you intend to end current activity and back to previous, use finish() instead “ Deep” Dive
  • 19.
    Make sure youstop services that is not needed upon exit! i.e. GPS service will otherwise continue to run in background By: Chua Zi Yong Singapore Android User Group www.codeandroid.org Remember to consider other parts of the lifecycle “ Deep” Dive
  • 20.
    By: Chua ZiYong Singapore Android User Group www.codeandroid.org Android Manifest User permission needed Declare activities within the application “ Deep” Dive
  • 21.
    Applications Debugging DDMSin Eclipse using ADB By: Chua Zi Yong Singapore Android User Group www.codeandroid.org “ Deep” Dive
  • 22.
    How to Publish?By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 23.
    How to Publish?Export and signing your app Export your application from Eclipse project Application will be exported as .apk Sign myapp.apk with Keytool and Jarsigner (within JDK) Take note on validity date of private key during keygen – recommend at least “10000 days” http://developer.android.com/guide/publishing/app-signing.html By: Chua Zi Yong Singapore Android User Group www.codeandroid.org Suggested commands $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000 $ jarsigner -verbose -keystore my-release-key.keystore my_application.apk alias_name
  • 24.
    How to Publish?Publishing on Android Market Sign up as an Android developer at developer.android.com USD$25 sign up fee Upload and monitor! By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 25.
    How to Publish?Market Business Policies Payment - 70% developer 30% telco Currently paid apps in UK and US No obscene materials (porn etc) 24 hour return policy Dispute resolution handled by developer and user directly Google holds the right to remove application if found of violation http://www.codeandroid.org/forum/?wpforumaction=viewtopic&t=1.0 By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 26.
    Resources By: ChuaZi Yong Singapore Android User Group www.codeandroid.org
  • 27.
    Resources Android Resourcesdeveloper.android.com Open Source Codes for Android Application code.google.com/hosting/ Online Tutorials www.anddev.org Developers Group Google Group (Android Beginner, Developer, Discuss) Codeandroid.org (Singapore Android User Group) By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 28.
    Resources GUI XMLTool for Android DroidDraw Hacking/Flashing Android ROMs XDA Developers List of all applications on Android Market http://www.cyrket.com/ By: Chua Zi Yong Singapore Android User Group www.codeandroid.org
  • 29.
    Q&A By: ChuaZi Yong Singapore Android User Group www.codeandroid.org ??