ESW #1 - Developing For Android


Published on

Here are some info by Alex Novac from Zitec regarding Android development.

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Battery Usage: various coding techniques can be used to minimize power consumption (like using reverse for loops) CPU Performance: various devices have different CPUs and the app should run smoothly on any off them. Device features: make sure the device you are running on has the feature you request. It is possible to run an Android app on a device that does not have a mobile connection or a phone book (think Tablet) Internet Connection: the type of the internet connection is important. Some data might be nice to display but uses a lot of bandwitdh (like pictures) and you can improve the user experience by detecting if they are on a fast and cheap (aka wifi) connection or on a high latency (aka mobile) connection.
  • Android uses JAVA as a base programming language, but C++ can be used, although it is not supported and there are not many resources available for this. Google provides a very good Eclipse plugin that helps/automates a lot off the tasks involved in development. The Android Development Toolkit includes debugger and emulators for all Android OS versions plus other tools that help in development. is the main resource for tutorials, help and references. 
  • Activities - provide interaction with the user. They are the windows of a desktop application or the webpages of a web application. Services - provide background processing. Services are equivalent to Linux daemons, Windows services or server-side cronjobs/processes. Broadcast receivers - provide a way for the OS or applications to inform other applications of various events that occur (eg. charging, docking, battery status, various user actions etc.) Content providers - create an uniform interface between applications to communicate public informations. Examples are the phone-book or the Messaging (SMS)
  • Activities have a life cycle that is important. Any activity can be killed by the system if it is running low on resources. The main method of inter-activities communication is the Intent object. The Intent object is the main method of communication between any Android objects.
  • the various states an activity may find itself in and the diagram of how it moves from one state to another. It is important to note that unless an activity is in the foreground its chance of being destroyed is pretty big.
  • onCreate is the main entry point of an Activity. Here you can do initialization of various Views contained in the Activity. onCreateOptionsMenu is responsible for returning the menu items to be used when the user presses (touches) the default Menu button on the device. onOptionsItemSelected getss called when a user has selected one off the menu options. There are methods in the Activity class that are called when the activity switches between its states (foreground, background etc)
  • not a smooth ride - switching between processes is not exactly like on a desktop computer . use home button and the app might be running or might get started again. bkg procs can be killed - if the OS is low on resources it will start killing background processes Services - no UI, functional only pieces of code intent-filter - a method of getting notified of various events. the OS will create a process and call it's BroadcastReceiver handlers if an event it has registered for occurs.
  • any activity in one application can call another exported activity from another application and read it's return code when that exits.  the new activity performs as if part of the first application but it runs on a separate process (flags are used for changing behavior) the return code can be a complex structures that incorporates whatever data the called activity wants to return to its caller
  • background processing - communication with servers time-consuming operations - parsing large amounts of data monitoring - checking various parameters at fixed time intervals. media playback - locally stored or streamed music playback
  • Notifications are a way for background processes to communicate with the user. They consist of an icon on the top bar of the device's UI and a message when the Notification screen is expanded. Clicking on a notification can trigger an application set action like starting an activity or executing a service command. BroadcastReceivers and Services cannot start activities but can pop-up notifications. They can populate a PendingIntent which is the Intent that they would like to be executed on their behalf.
  • do a lot of checks - things are more volatile in the mobile platform workflow - understand the steps that an activity or service moves trough settings manager - android has a default settings manager that handles setting everything for you coding guides - there are both design and coding guides that offer a lot of hints for beginners don't bloat your app - it's a mobile application and it should do one thing and do it well stay up to date- android is an emerging platform, things change a lot and ppl find out new ways of developing every day.
  • ESW #1 - Developing For Android

    1. 1. Developing for Android a quick introduction by Alex Novac   Zitec CTO & Founding Partner
    2. 2. INDEX <ul><ul><li>Concerns regarding mobile platforms </li></ul></ul><ul><ul><li>Developing applications for Android. How? </li></ul></ul><ul><ul><li>The structure of an Android application. Activities </li></ul></ul><ul><ul><li>Multitasking in Android </li></ul></ul><ul><ul><li>Inter-application communication </li></ul></ul><ul><ul><li>Background processing (Services) </li></ul></ul><ul><ul><li>Notification system </li></ul></ul>
    3. 3. Concerns Regarding Mobile Platforms <ul><ul><li>Battery Power Usage </li></ul></ul><ul><ul><li>CPU performance </li></ul></ul><ul><ul><li>Device Features - WiFi, GPS, Bluetooth etc. </li></ul></ul><ul><ul><li>Internet Connection and its type (WiFi, 3G) </li></ul></ul>
    4. 4. Developing Applications for Android <ul><ul><li>Android uses JAVA as a base programming language </li></ul></ul><ul><ul><li>Google provides a very good Eclipse plugin </li></ul></ul><ul><ul><li>The Android Development Toolkit </li></ul></ul><ul><ul><li> - references, tutorials & help </li></ul></ul>
    5. 5. The Structure of an Android app <ul><ul><li>Activities </li></ul></ul><ul><ul><li>Services </li></ul></ul><ul><ul><li>Broadcast receivers </li></ul></ul><ul><ul><li>Content providers </li></ul></ul>
    6. 6. Activities <ul><li>Activities are the main method of interaction between the user and the applications. </li></ul>
    7. 7. Life cycle of Activities <ul><ul><li>create </li></ul></ul><ul><ul><li>start (restart) </li></ul></ul><ul><ul><li>resume </li></ul></ul><ul><ul><li>running </li></ul></ul><ul><ul><li>pause </li></ul></ul><ul><ul><li>stop </li></ul></ul><ul><ul><li>destroy </li></ul></ul>
    8. 8. Activities <ul><li>public class SharoidActivity extends Activity { </li></ul><ul><li>@Override </li></ul><ul><li>protected void onCreate (Bundle savedInstanceState) { </li></ul><ul><li>super.onCreate(savedInstanceState); </li></ul><ul><li>setTitle( &quot;Sharoid&quot; ); </li></ul><ul><li>                 setContentView (R.layout.sharoid); </li></ul><ul><li>} </li></ul><ul><li>@Override </li></ul><ul><li>public boolean onCreateOptionsMenu (Menu menu) { </li></ul><ul><li>    MenuInflater inflater = getMenuInflater(); </li></ul><ul><li>    inflater.inflate(, menu); </li></ul><ul><li>    return true; </li></ul><ul><li>} </li></ul><ul><li>@Override </li></ul><ul><li>public boolean onOptionsItemSelected (MenuItem item) { </li></ul><ul><li>    switch ( item.getItemId() ) { </li></ul><ul><li>    case </li></ul><ul><li>    Intent friends_intent = new Intent( this , SharoidListActivity.class ); </li></ul><ul><li>    friends_intent.putExtra( &quot;list_ws&quot; , fixRelativeURL( &quot;/sharoid/get-friends&quot; ) ); </li></ul><ul><li>    startActivity ( friends_intent ); </li></ul><ul><li>    break; </li></ul><ul><li>    } </li></ul><ul><li>    return false; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
    9. 9. Multitasking in Android <ul><ul><li>not a very smooth ride </li></ul></ul><ul><ul><li>background processes can be killed by the OS </li></ul></ul><ul><ul><li>main method is trough Services </li></ul></ul><ul><ul><li>the intent-filter system helps interaction </li></ul></ul>
    10. 10. Inter-application communication <ul><ul><li>call an Activity from another application </li></ul></ul><ul><ul><li>get a response form that Activity </li></ul></ul><ul><ul><li>extend your apps functionality </li></ul></ul>
    11. 11. Services <ul><ul><li>background processing </li></ul></ul><ul><ul><li>time-consuming operations </li></ul></ul><ul><ul><li>monitoring </li></ul></ul><ul><ul><li>media playback </li></ul></ul>
    12. 12. Notification system <ul><li>allow background processes to communicate with the user. </li></ul>
    13. 13. Final notes <ul><ul><li>do a lot of checks </li></ul></ul><ul><ul><li>understand the workflow of the Activities and Services </li></ul></ul><ul><ul><li>use the standard settings manager </li></ul></ul><ul><ul><li>read the coding and design guides </li></ul></ul><ul><ul><li>don't bloat the application </li></ul></ul><ul><ul><li>stay up to date with the information </li></ul></ul>
    14. 14. Questions and Answers <ul><li>Follow us on twitter and don't hesitate to ask questions: </li></ul>@acidtrix  @zitec @sharoider