An Introduction to Android Application Serdar Akın, Haluk Tüfekçi ARDIC ARGE http://www.ardictech.com April 2011
Environment Programming Languages Java (Officially supported) C (Android NDK Needed) C++ (Android NDK Needed) Android Software Kit (SDK) Dalvik Cross Assembler Class Library Android Debug Bridge (adb) Documentation Dalvik Debug Monitor Service (ddms) Sample Codes Android Emulator System Images Native Kit (NDK) USB Driver (OEM USB drivers may be installed) Integrated Environment Galileo Java Tools Java Kit 5 or 6 Android Tools Plugin Operating System Ubuntu Computing System
Environments Eclipse Android SDK Android Environment Hello, World Android Device APPLICATIONS Home Contacts Phone Browser Built-In Applications User Applications Application Life Cycle, API, s Package Activity Telephony APPLICATION FRAMEWORK Window Resource Content Providers Location View Systems Notification Accessible through JNI, C/C++ Libraries, UI, Graphics, Media Surface OpenGL ES SGL (2D graphics) LIBRARIES Media Framework FreeType SSL SQLite WebKit bionic ANDROID RUNTIME Java Core Libraries Dalvik Virtual Machine Optimized virtual machine, Java Core Libraries Display Driver Keypad Driver Camera Driver WiFi Driver LINUX KERNEL Flash Memory Driver Audio Driver Binder (IPC) Driver Power Management Process Man. Memory Man. Drivers, HAL Security Inter-process Communication
Application Framework Activity View Resource Content Providers Application lifecycle Navigation Programmable controls List, Grid, Textbox, Button, Embedded web browser Localized strings Graphics Layout files Access data Share data Notification Custom alerts for end user Window Screen organization Surface allocation for applications Package Application Installation
Hello, World package com.google.android.helloworldactivity; import android.app.activity; import android.os.bundle; public class HelloWorldActivity extends Activity { public HelloWorldActivity() { } @Override public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.helloworld_activity); } }
Application Structures Activity Intent Broadcast Receiver Content Provider Service Resource A single, focused screen that the user can do Intents are used for inter-communication among activities or services An intent is a data structure that stores a message A broadcast receiver triggers an intent to start an application A content provider is an interface to store and retrieve data and make it accessible to all applications Services run in the background for an indefinite period of time They have no user interface interaction Externalization of strings and graphics
Application Lifecycle Activity starts oncreate() User navigates back to the activity onstart() onresume() onrestart() Process is killed Activity is running Another activity comes in front of the activity The activity comes to the foreground Other applications need memory onpause() The activity is no longer visible The activity comes to the foreground onstop() ondestroy() Activity is shut down
Views and Layouts Parent Layout Child Layout Child Layout Label Child Layout Text Box Text Box Button
Layouts Linear Layout Vertical Horizontal Relative Layout Table Layout Frame Layout * Absolute Layout is deprecated
View Examples GridView TabView MapView WebView
Key points In Android Application Performance and battery life is important in mobile devices Recycle java objects Avoid floating point arithmetic Use efficient data format and parser Reduce transferred data size, gzip text data Keep memory small in order not to be killed Services Do not use services as daemons Start them with Alarm only when device is awake Use receivers to awaken services Check battery life and do not run heavy jobs if battery is critical
References http://developer.android.com/guide/index.html http://androidappdocs.appspot.com/index.html