Report On Android Mobile Application Devlopment
Report On Android Mobile Application Devlopment
AT
Faculty of Science and Technology The ICFAI University, Dehradun 2nd January, 2012- 15th June, 2012
Faculty of Science and Technology The ICFAI University, Dehradun 2nd January, 2012- 15th June, 2012
CERTIFICATE
This is to certify that the project work ANDROID MOBILE APPLICATION DEVELOPMENT, has been carried out by Mr. Shahjahan khan (I.D. No. 08DDCS17), during the Internship Program III which was commenced for the period of January 02 to June 15 of the year 2012. It is certified that all corrections / suggestions indicated have been incorporated in the report. The project has been approved as it satisfies the academic requirements in respect of Internship Program III.
Signature of IP Faculty
ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany the successful completion of any task would be incomplete without the mention of the people who made it possible, whose consistent guidance and encouragement crown all the efforts. I express my gratitude and appreciation for all those with whom I worked and interacted at Sevya IT Pvt. Ltd, Hyderabad and thank all of them for their help and co-operation. I would like to express my reverence to Dr. Ramesh Ramola, Dean, ICFAI University, Dehradun, for allowing me to take this course on Internship Program-III. I am thankful to Mr. Srikant Modugula, Managing Director, and Mr. Narasayya Donepudi, Director Sevya IT Pvt. Ltd for providing me an opportunity to work in this elite Organization. I owe my sincere gratitude to Kumar Raja Donthamsetti and Vineet Agrawal, Mobile Application Developer Sevya IT Pvt. Ltd for their useful guidance, invaluable advices and suggestions at every stage of the project, without which it would have been hardly possible to complete the task. It is a great privilege to have an opportunity to work and learn a lot under their guidance. I am grateful to Dr. G.S. Brahma, IP in-charge, Faculty of Science and Technology, ICFAI University, Dehradun for allowing me to carry out my project at Sevya Multimedia, Hyderabad. I owe appreciation to my parents for the support they have extended to me during the session. Last but not the least, I would like to thank all my friends who directly or indirectly helped me, and made me complete this project on time.
IV
Date of Submission: 15th June, 2012 Title of the project: Android Mobile Application Development
Name(s) and Designation(s) of the Expert(s): Mr Srikant Modugula (Director), Mr Narasayya Donepudi (Director), Mrs.Sivaparvathi Avula (HR), Mr Kumar Raja Donthamsetti (Mobile Application Developer), Mr Vineet Agarwal (Mobile Application Developer) Name of the IP Faculty: Key Words: Project Areas: Abstract: Dr.Gouri Sankhar Brahma Mobile Application Development, Android Application Development Training This project deals with Android Application and Database Synchronization. Which includes application developed using Android SDK and Java Platform. The report in brief describes about installation, User Interface Oracle to SQLite Synchronization and VLSI conference as an application.
TABLE OF CONTENTS
ACKNOWLEDGEMENT...................IV ABSTRACT..........V 1. 2. INTRODUCTION ......................................................................................................... 1 BIRTH OF ANDROID .................................................................................................. 2 2.1 2.2 Foundation .............................................................................................................. 2 Google Acquires Android Inc. ................................................................................. 2 Open Handsets Alliance Founded..................................................................... 2 Hardware ......................................................................................................... 2
2.2.1 2.2.2 3.
FEATURE .................................................................................................................... 4 3.1 3.2 3.2 3.3 3.4 3.5 3.6 Application Framework........................................................................................... 4 Dalvik Virtual Machine ........................................................................................... 5 Integrated Browser .................................................................................................. 5 Optimized Graphics ................................................................................................ 5 Connectivity............................................................................................................ 5 Data Storage ........................................................................................................... 5 Media Support ........................................................................................................ 6 Audio ............................................................................................................... 6 Image ............................................................................................................... 6 Video ............................................................................................................... 6
Messaging ............................................................................................................... 7
ARCHITECTURE......................................................................................................... 8
4.1
Android Main Architecture ..................................................................................... 8 Application ...................................................................................................... 9 Application Framework ................................................................................... 9 Libraries ........................................................................................................ 10 Android Runtime ........................................................................................... 11 Kernel-Linux ................................................................................................. 12
REQUIREMENTS & SETUP TO START .................................................................. 20 5.1 5.1 5.2 Platform ................................................................................................................ 20 Eclipse............................................................................................................... 20 Tools/Kit ............................................................................................................... 21 Java Development Kit(JDK) .......................................................................... 21 Android Developer Tools Plug-in (ADT) ....................................................... 22 Android Software Development Tools (SDK) ................................................ 22
HELLO ANDROID PROGRAM ................................................................................ 27 6.1 Creating New Android Project .............................................................................. 27 Details of Fields ............................................................................................. 28
6.1.1
6.2
Project Structure ................................................................................................... 30 AndroidMainfest.xml ..................................................................................... 30 Resource folder (res) ...................................................................................... 31 Src Directory ................................................................................................. 31 Bin Directory ................................................................................................. 31 Lib Directory ................................................................................................. 31
Running and Debugging........................................................................................ 32 Source code ................................................................................................... 32 Building Application Process ......................................................................... 33 Result ............................................................................................................ 34
LIFE CYCLE .............................................................................................................. 35 7.1 Activity Life Cycle ............................................................................................... 35 Activity .......................................................................................................... 35 Starting State ................................................................................................. 36 Running State ................................................................................................ 37 Paused State ................................................................................................... 37 Stop State....................................................................................................... 37 Destroyed State .............................................................................................. 38
Android Application Life Cycle ............................................................................ 38 Foreground process ........................................................................................ 39 Visible Process .............................................................................................. 39
7.2.1 7.2.2
CONFERENCE APPLICATION ................................................................................ 41 8.1 8.2 Description of VLSI 2012 ..................................................................................... 41 Source Code.......................................................................................................... 42 Creating Tab .................................................................................................. 43
8.2.3 8.3
Results .................................................................................................................. 46 Conference Tab .............................................................................................. 46 Tutorials Tab ................................................................................................. 47 Exhibition Tab ............................................................................................... 48 Other Tab....................................................................................................... 49
ORACLE TO SQLITE (ANDROID) SYNCHRONIZATION ..................................... 50 9.1 Oracle Mobile Server 11g ..................................................................................... 50 Key Feature ................................................................................................... 50 Components ................................................................................................... 51 Architecture ................................................................................................... 52
Android Mobile Client .......................................................................................... 52 Components ................................................................................................... 53 Architecture ................................................................................................... 53 Process of Data Sync...................................................................................... 54
9.3 10.
1. INTRODUCTION
Android is a software stack for mobile devices that includes an operating system, middleware and key applications. Android is a software platform and operating system for mobile devices based on the Linux operating system and developed by Google and the Open Handset Alliance. It allows developers to write managed code in a Java-like language that utilizes Google-developed Java libraries, but does not support programs developed in native code. The unveiling of the Android platform on 5 November 2007 was announced with the founding of the Open Handset Alliance, a consortium of 34 hardware, software and telecom companies devoted to advancing open standards for mobile devices. When released in 2008, most of the Android platform will be made available under the Apache free-software and open-source license.
INTRODUCTION
2. BIRTH OF ANDROID
2.1 Foundation
Android Inc was founded by Andrew E. Rubin in Octobers 2003, in Palo Alto, California United State America. Later on it is emerged with Google.
2.2
In July 2005, Google acquired Android Inc., a small startup company based in Palo Alto, CA. Android's co-founders who went to work at Google included Andy Rubin (co-founder of Danger), Rich Miner (co-founder of Wildfire Communications, Inc), Nick Sears (once VP at T-Mobile), and Chris White (one of the first engineers at WebTV). At the time, little was known about the functions of Android Inc. other than they made software for mobile phones. 2.2.1 Open Handsets Alliance Founded On 5 November 2007, the Open Handset Alliance, a consortium of several companies which include Google, HTC, Intel, Motorola, Qualcomm, T-Mobile, Sprint Nextel and NVIDIA, was unveiled with the goal to develop open standards for mobile devices. Along with the formation of the Open Handset Alliance, the OHA also unveiled their first product, Android, an open source mobile device platform based on the Linux operating system. 2.2.2 Hardware Google has unveiled at least three prototypes for Android, at the Mobile World Congress on February 12, 2008. One prototype at the ARM booth displayed several basic Google applications. Ad-pad' control zooming of items in the dock with a relatively quick response.
BIRTH OF ANDROID
ANDROID MOBILE APPLICATION DEVELOPMENT A prototype at the Google IO conference on May 28, 2008 had a 528 MHZ Qualcomm processer synaptic capacitive touch screen, and used the UMTS cellular standard. It had 128 MB of RAM and 256 MB of flash, showing that Android memory requirements are reasonable. The Demo was carried out using a 3.2Mbits/HSDPA connection
BIRTH OF ANDROID
3. FEATURE
Android provide so many feature, like camera, GPS, connectivity etc. following are list of feature. Application framework Dalvik virtual machine Integrated browser Optimized graphics Handset layout Connectivity Messaging Data storage Web browsers Media support
Android support all the above feature, some of features are same for all the version of Android and some are improve according to new version.
3.1
Application Framework
It is used to write application for android unlike other embedded mobile environments, Android applications are all equals, for instance, an application which comes to the phone are no different than any developer writes. The framework based on UNIX file system and supported by numerous open source libraries such as openssl. Since it based on UNIX so it more secure as well.
FEATURE
3.2
It is register-based virtual machine for android mobile platforms; it is designed such that it can run on embedded system and consume low-power. It is also based on low memory virtual machine. Using dx tools DVM create .dex (Dalvik executable) file format when compile the program, and turn in Zipped into a single .apk format.
3.2
Integrated Browser
It is built off of the open-source Web Kit browser engine. Web Kit provides the basic functionality
that allows a Web browser to convert a webpage's HTML code into a viewable site. This feature
3.3
Optimized Graphics
Android includes support for high performance 2D and 3D graphics with the Open Graphics library that called OpenGL through its framework API and the Native Development Kit (NDK).These concept are used in so many application of android like Google Earth, etc.
3.4
Connectivity
Android support wide verity of connectivity, like Wi-Fi, GSM, CDMA, Bluetooth, EDGE, etc.
3.5
Data Storage
Android provides several options for you to save persistent application data. SQLite is used structured, which is very lightweight powerful relational database for users. It is in build with android.
FEATURE
3.6
Media Support
Android support Audio, Video, Image, and different type of file system for audio video and image 3.6.1 Audio The most usable audio file format and extension for android is as follow. 3GPP(.3gp) MPEG-4(.mp4,.m4a) MP-3(.mp3) 3.6.1 Image The most usable image file format and extension which is supported by android is as follow. JPEG(.jpg) PNG(.png) BMP(.bmp) GIF(.gif) 3.6.3 Video The most usable Video file format and extension for android is as follow. 3GPP(.3gp) MPEG-4(.mp4,.m4a) MP-3(.mp3)
FEATURE
3.7
Messaging
Android support message, which are available in form of SMS, MMS, and XMPP as well as it also support thread text messaging.
FEATURE
4. ARCHITECTURE
Basically android have two types of architecture, the 1 st is main and 2nd is for UI which is as follow. Android Main Architecture Android GUI Architecture Android Data Storage Architecture
4.1
It is explained using following figure which contain the main components of android operating system.
Fig 4.1: Android Architecture This architecture contains mainly following these components. Application Application Framework
ARCHITECTURE
ANDROID MOBILE APPLICATION DEVELOPMENT Android Runtime Kernel-Linux 4.1.1 Application These are applications written in Java. Some of basic applications include calendar, email client, SMS program, maps, making phone calls, accessing the Web browser, accessing your contacts list and others. For beginner this layer is very useful. Other layer is more used by Google programmer and hardware manufacturers. 4.1.2 Application Framework This is the skeleton or framework which all android developers have to follow. The developers can access all framework APIs an manage phones basic functions like resource allocation, switching between processes or programs, telephone applications, and keeping track of the phones physical location. Developers have full access to the same framework APIs used by the core applications. The application architecture is designed to simplify the reuse of components; any application can publish its capabilities and any other application may then make use of those capabilities (subject to security constraints enforced by the framework). This same mechanism allows components to be replaced by the user. A rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser. Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data
ARCHITECTURE
ANDROID MOBILE APPLICATION DEVELOPMENT A Resource Manager, providing access to non-code resources such as localized strings, graphics, and lat files. A Notification Manager that enables all applications to display custom alerts in the status bar. An activity manager that manages the life cycle of applications and provides a common navigation back stack 4.1.3 Libraries Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework. Some of the core libraries are listed below: System C library - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices Media Libraries - based on Packet Videos Open CORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG Surface Manager - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications LibWebCore - a modern web browser engine which powers both the Android browser and an embeddable web view SGL - the underlying 2D graphics engine
ARCHITECTURE
10
ANDROID MOBILE APPLICATION DEVELOPMENT 3D libraries - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software pasteurizer. 4.1.4 Android Runtime Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language. Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool. The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management. At the same level there is Android Runtime, where the main component Dalvik Virtual Machine is located. It was designed specifically for Android running in limited environment, where the limited battery, CPU, memory and data storage are the main issues. Android gives an integrated tool dx, which converts generated byte code from .jar to .dex file, after this byte code becomes much more efficient to run on the small processors.
ARCHITECTURE
11
ANDROID MOBILE APPLICATION DEVELOPMENT As the result, it is possible to have multiple instances of Dalvik virtual machine running on the single device at the same time. The Core libraries are written in Java language and contains of the collection classes, the utilities, IO and other tools. 4.1.5 Kernel-Linux This layer includes Androids memory management programs, security settings, power management software and several drivers for hardware, file system access, networking and inter-process-communication. The kernel also acts as an abstraction layer between hardware and the rest of the software stack. This includes the following feature. WCDMA/HSUPA and EGPRS network support 2. Bluetooth 1.2 and Wi-Fi support 3. Digital audio support for mp3 and other formats Support for Linux and other third-party operating systems Java hardware acceleration and support for Java applications Cameras up to 6.0 megapixels GPS solution for GPS
4.2
The Android environment adds yet another Graphical User Interface (GUI) toolkit to the Java ecosphere, joining AWT, Swing, SWT, and J2ME (leaving aside the web UI toolkits). If youve worked with any of these, the Android framework will look familiar. Like them, it is single-threaded, event-driven, and built on a library of nest able components.
The Android UI framework is, like the other UI frameworks, organized around the common Model-View-Controller pattern illustrated in Figure. It provides structure and tools for
ARCHITECTURE
12
ANDROID MOBILE APPLICATION DEVELOPMENT building a Controller that handles user input (like key presses and screen taps) and a View that renders graphical information to the screen. The Android UI framework is organized around the common Model-View-Controller pattern.
Following figure show the components of GUI architecture.
According to architecture it has mainly three components as follow. Model View Controller 4.2.1 Model The model represents data or data container. You can see it as a database of pictures on your device. Say, any user wants to hear an audio file, he clicks play button and it triggers an event
ARCHITECTURE
13
ANDROID MOBILE APPLICATION DEVELOPMENT in your app, now the app will get data from data store or database and as per input and creates data to be sent back to the user. You can refer this data as Model. Single Model might be used by several different applications e.g.: An MP3 player and an application that converts MP3 files into WAV files. For both applications, the Model includes the MP3 file format and codes for it. The former application, however, has the familiar Stop, Start, and Pause controls, and plays the track. The latter may not produce any sound at all; instead, it will have controls for setting bitrates, etc. The Model is all about the data. 4.2.2 View The View is the application's feedback to the user. It is the portion of the application responsible for rendering the display, sending audio to speakers, generating tactile feedback, and so on. The graphical portion of the Android UI framework's View
Fig 4.5: Android Music Player Above example, the display in a hypothetical MP3 player might contain a component that shows the album cover for the currently playing tune. Another component might display the
ARCHITECTURE
14
ANDROID MOBILE APPLICATION DEVELOPMENT name of the currently playing song, while a third contains subcomponents such as the Play, Pause, and Stop buttons. The Android UI framework is actually quite a bit more efficient than this oversimplified description suggests. It does not paint an area of a parent view if it can be certain that some child will later paint the same area, because it would be a waste of time to paint background underneath an opaque object! It would also be a waste of time to repaint portions of a view that have not changed. 4.2.3 Controller The Controller is the portion of an application that responds to external actions: a keystroke, a screen tap, an incoming call, etc. It is implemented as an event queue. Each external action is represented as a unique event in the queue. The framework removes each event from the queue in order and dispatches it. For example, when a user presses a key on his phone, the Android system generates a Key event and adds it to an event queue. Eventually, after previously enquired events have been processed, the Key Event is removed from the queue and passed as the parameter of a call to the dispatch Key Event method of the View that is currently selected.
4.3
The following diagram so how the android mobile user connect with the data base using the credentials in android and which type of security is provided by the android os.
ARCHITECTURE
15
Fig 4.6: Secure Data storage in Android The following steps are showing how the user connects to data base and android application retrieve the data base from web service and SSO server as well. 1. The user enters his credentials on the handset. 2. The credentials are not sent to the SSO service over the network. Instead, the credentials are used as the passphrase to decrypt the local public/private key pair of the user. We define the public/private key pair to be of type RSA and of at least 4096 bits in size. Already we gain the advantage that the users password is not sent over the network. 3. The private key is used to decrypt the symmetric cipher key. The symmetric cipher key is used to encrypt/decrypt any locally cached data. A strong symmetric cipher like 3DES is used. 4. All data found in the local cache is encrypted with the symmetric cipher key defined in step 3.
ARCHITECTURE
16
ANDROID MOBILE APPLICATION DEVELOPMENT 5. If the requested data is not locally cached or expired. We must communicate with the SSO service again to be able to receive fresh data from the Restful web services. However, unlike the architecture presented in section 2 of this document, we login to the SSO server using a hostile challenge based on the private key of the user. As such, we login with the SSO system using public/private key infrastructure. The user name and the password are never sent over the network. The SSO system can identify the user based on this challenge and returns a 496 bit alpha numeric token. 6. The tokens generated by the SSO system are set to automatically expire after a given period of time. 7. On reception of the SSO token. The Android background application can now communicate with any Restful web services that adhere to the same SSO federation. Public/private key infrastructure is once again used to setup a secure communication channel between the phone and the server. The certificates of the servers that host the Web services are procured from the same certificate authority that shipped with the phone. 8. On reception of a request, the SSO token is extracted from the request. The web service calls upon the SSO system to authorize the operation. 9. On reception of the data, the symmetric cipher described in bullet #3 above is used to encrypt the data before it reaches any local persistent storehouse. 10. Data is returned to the user facing application. Additional security Notes as follow 1. The public/private key pair of the user is generated directly on the handset at install time. As such, the private key has never left the phone nor has it been transferred over any network.
ARCHITECTURE
17
ANDROID MOBILE APPLICATION DEVELOPMENT 2. The certificate of the user must at least be registered once in the SSO application. This could be done at install time of the handset application. 3. Man-in-the-middle38 attacks are not possible since the application is deployed with the CA certificate of the company that will be hosting the web services. 4. If the device is lost, all the locally cached data is completely unreadable. The symmetric key that encrypted this data is also unreadable. The public/private keys that are central to the security architecture are protected by a passphrase. 5. The passphrase is the weakest link in the chain. If the user enters an overly simple password, access could be gained to the private key and hence the locally cached data. 6. That being said, it would be possible to further extend this architecture to store the encrypted symmetric key on the server. This way, even if the passphrase of the private key is compromised, the locally cached data still cannot be accessed. This is because the encrypted strong symmetric cipher key is stored on the server. By the time the passphrase has been cracked, there has been ample time to report the stolen phone and revoke this key from this user account on the server. Furthermore, under this scheme, the key stored on the server is still encrypted. Even if this key is intercepted in transit it is useless without the users private key. 7. It is also possible to enforce a strong password policy directly from the handset application. 8. Even if this design is significantly more secure than the previous iteration, to the user, the experience is the same. The user must enter a username and password to prove his identify. 9. We could augment the architecture in yet another direction. The local caching system could also require an SSO token and subsequently request authorization from an SSO
ARCHITECTURE
18
ANDROID MOBILE APPLICATION DEVELOPMENT system. Such a design would prevent terminated employees, i.e., an Individual who already knows what the local credentials are, from accessing the locally cached data.
ARCHITECTURE
19
Download all the above requirements from their respective site. An important thing is it is all of above software should mach the version as well. Like for Eclipse Indigo (3.7.2) JDK version should have 1.6 or more.
5.1
Platform
For developing any application we have to need some platform like Net bean for java based application visual studio frame work for many types of language. Here we are using eclipse as a platform for developing android application. 5.1 Eclipse
The Eclipse Platform is designed for building integrated development environments (IDEs). It can be used to create diverse end-to-end computing solutions for multiple execution environments
20
Fig 5.1: Eclipse Indigo Eclipse indigo is recent version of eclipse; there is also previous version like Galileo, Helios, etc. Download from the eclipse site for windows, Linux, or Mac operating system.
5.2
Tools/Kit
5.2.1 Java Development Kit(JDK)
A Java Development Kit (JDK) is a program development environment for writing Java applications. It consists of a runtime environment that "sits on top" of the operating system layer as well as the tools and programming that developers need to compile, debug, and run applications written in the Java language. Since android support for java so first step is download the JDK and install. After that unzip the download Eclipse and click on .exe file.
21
ANDROID MOBILE APPLICATION DEVELOPMENT 5.2.2 Android Developer Tools Plug-in (ADT) It is a plug-in for Eclipse that provides a suite of tools that are integrated with the Eclipse IDE. It offers you access too many features that help you develop Android applications quickly. ADT provides GUI access to many of the command line SDK tools as well as a UI design tool for rapid prototyping, designing, and building of your application's user interface. Following step are involved in ADT plug-in for Eclipse. 1. Start Eclipse, then select Help > Install New Software 2. Click Add, in the top-right corner. 3. In the Add Repository dialog that appears, enter ADT for the Name and for Location enter the URL https://dl-ssl.google.com/android/eclipse/ and click ok. 4. In the Available Software dialog, select the checkbox Developer Tools and click Next 5. In the next window, there will be a list of the tools to be downloaded Click Next . 6. Read and accept the license agreements, then click Finish. 7. Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click ok. 8. When the installation completes, restart Eclipse. 5.2.2 Android Software Development Tools (SDK) It enables developers to create application for the Android platform. The
Android SDK includes sample projects with source code, development tools, an emulator, and required libraries to build Android applications. Applications are written using the Java programming language and run on Dalvik, a custom virtual machine designed for embedded use which runs on top of a Linux kernel.
22
ANDROID MOBILE APPLICATION DEVELOPMENT After setup ADT plug-in for Eclipse it is asking for Location of SDK or to download select location from existing directory where SDK is downloaded. Following steps are involved to edit the location of SDK in Eclipse. 1. Start Eclipse > windows > preference to open preference window 2. Select Android from left panel of preference window 3. Finally browse the SDK from directory where it is downloaded 4. Next step is to handle and update SDK through SDK manager. It includes the most important tools as follows. Android Software Development Kit Manager (SDK Manager ) Android Virtual Device Manager(AVD Manager) Android Emulator
These are the most important tools which is help during the development of android application. SDK Manager It is used for adding and updating individual packages in android SDK and makes it easy and very fast. It only takes a couple of clicks to install individual versions of the Android platform, new development tools, new documentation, and SDK add-ons. The new SDK packages are automatically installed into your existing SDK directory, so you don't need to update your development environment to specify a new SDK location.
23
Fig 5.2: SDK Manager AVD Manager It is device configuration for the Android emulator that allows you to model different configurations of Android-powered devices. When you start the AVD Manager in Eclipse or run the android tool on the command line following fig will open.
24
ANDROID MOBILE APPLICATION DEVELOPMENT To create virtual device (AVD) follows these steps. 1. Start Eclipse > Select windows > AVD Manager to open AVD Manager 2. A windows will open like above image, click on New button a following window will open
Fig 5.4: AVD 3. Fill the all details in window then click on create AVD. A window will open 4. Click on Start button a after selecting the Android2_2 in Fig 10. Emulator will start. Android Emulator It is a virtual mobile device that runs on your computer. The emulator used to develop and test Android applications without using a physical device. But it has some limitation or fewer features than mobile device. The following feature are not contain by android Emulator . REQUIREMENTS & SETUP TO START 25
ANDROID MOBILE APPLICATION DEVELOPMENT No support for placing or receiving actual phone calls. You can simulate phone calls No support for USB connections No support for camera/video capture (input). No support for device-attached headphones No support for determining connected state No support for determining battery char level and AC charging state No support for SD card No support for Bluetooth.
26
6.1
Following Step are required to create first android project 1. In Eclipse, select File > New > Project.... 2. If the ADT Plug-in for Eclipse has been successfully installed, the resulting dialog should have a folder labeled "Android" which should contain "Android Project". (After you create one or more Android projects, an entry for "Android XML File" will also be available.) 3. Select "Android Project" and click next. 4. Fill in the project details with the following values: Project Name : HelloAndroid Build Target Select a platform version that is equal to or lower than the target you chose for your AVD Application Name : Hello, Android Package Name : com.example.helloandroid Activity : HelloAndroid
5. Click finish
27
ANDROID MOBILE APPLICATION DEVELOPMENT 6.1.1 Details of Fields In process of creating Android project some fields have filled which in above step 4. Following picture show that fields and it is explain in details as follows.
28
ANDROID MOBILE APPLICATION DEVELOPMENT Project Name This is the Eclipse project name the name of the directory that contains the project files. Built Target This is the version of the Android SDK that you're using to build your application. Application Name This is the human-readable title for your application the name that appears on the Android device. Package Name This is the package namespace (following the same rules as for packages in the Java programming language) that you want all your source code to reside under. Package name must be unique across all packages installed on the Android system. Create Activity This is the name for the class stub that is generated by the plug-in. This is a subclass of Android's Activity class. An Activity is simply a class that can run and do work. It can create a UI if it chooses. Android project may have more than one activity class. This will discuss later. Minimum SDK version This value specifies the minimum API Level on which your application will run. The Min SDK Version should be the same as the Build Target you chose. For example, if the Build Target is Android 2.1, then the Min SDK Version should be 7. And android project created successfully. In left panel of Eclipse it will display.
29
6.2
Project Structure
In the left panel the project structure will be showed which contain following items shown in the picture
Fig 6.2: Project structure Above figure show the structure of HelloAndroid project which is created earlier in this chapter. They contain some important items in project root directory as follows. AndroidMainfest.xml Src Bin Res 6.2.1 AndroidMainfest.xml The foundation for any android application. This is where you declare what is inside your applicationthe activities, the services, permission and etc. example
30
ANDROID MOBILE APPLICATION DEVELOPMENT <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloworld" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".HelloAndroidActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 6.2.2 Resource folder (res) In android this directory plays very important for any android application, it is useful to hold the all resources such as icon, GUI layouts, colors, etc. 6.2.3 Src Directory The directory that holds the Java source code for the android application. In this case HelloAndroidActivity.java .other java class also added by R.C >new >class. 6.2.4 Bin Directory The directory that holds the application once it is compiled. 6.2.5 Lib Directory The directory that holds any third-party JARs your application requires
31
6.3
Before running and debugging android application source can changed according to requirement of application. And after run or build how the source code converted in .apk file which can be used in any mobile device having android os. 6.3.1 Source code 1. HelloAndroidActivity.java file contain package com.example.helloworld; import android.app.Activity; import android.os.Bundle; public class HelloAndroidActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } 2. Now other file is also has important role in design the layout for android application is main.xml file is in layout folder of res directory. Design of layout can be through java code as. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >
32
</LinearLayout> 6.3.2 Building Application Process Following step are take place during build android application, and below picture show how java code convert into .apk file. During the build process, Application compiled and packaged into an .apk file, the container for your application binary. It contains all of the information necessary to run your application on a device or emulator, such as compiled .dex files (.class files converted to Dalvik byte code), a binary version of the AndroidManifest.xml file, compiled resources (resources.arsc) and un compiled resource files for your application. If you are developing in Eclipse, the ADT plug-in incrementally builds your project as you make changes to the source code. Eclipse outputs an .apk file automatically to the bin folder of the project, so you do not have to do anything extra to generate the .apk. To run an application on an emulator or device, the application must be signed using debug or release mode. The following diagram depicts the components involved in building android application.
33
Fig 6.3: Build Process 6.3.2 Result To run android project R.C on project >Run android application then emulator will open and following output as result.
34
7. LIFE CYCLE
Android life cycle is categories in two following components. Activity Life cycle Android Application Life Cycle
Since Activity is an internal components of any android application so whenever an android application start an activity is launch and according to its cycle is destroy which will show later but an application have more than one activity, if life of application is different as life of activity. So it is typed in two categories.
7.1
Before going to explain activity live cycle there should be brief introduction of Activity 7.1.1 Activity An activity is usually a single screen that the user sees on the device at one time. An application typically has multiple activities, and the user flips back and forth among them. As such, activities are the most visible part of your application. A very important to developer is every activity should called from AndroidMainfest. It is above explained how an activity create for application. Launching an activity can be quite expensive. It may involve creating a new Linux process, allocating memory for all the UI objects, inflating all the objects from XML layouts, and setting up the whole screen. Since were doing a lot of work to launch an activity, it would be a waste to just toss it out once the user leaves that screen. To avoid this waste, the activity life
LIFE CYCLE
35
ANDROID MOBILE APPLICATION DEVELOPMENT cycle is managed via Activity Manager, which responsible for creating, destroying, and managing activities. Following Image show the Activity cycle and up to what extend it alive.
Fig 7.1: Activity Life Cycle 7.1.2 Starting State When an activity doesnt exist in memory, it is in a starting state. While its starting up, the activity will go through a whole set of callback methods that you as a developer has an opportunity to fill out. Eventually, the activity will be in a running state Keep in mind that this transition from starting state to running state is one of the most expensive operations in terms of computing time, and this also directly affects the battery life of the device. This is the exact reason why we dont automatically destroy activities that are no longer shown. The user might want to come back to them, so we keep them around for a while.
LIFE CYCLE
36
ANDROID MOBILE APPLICATION DEVELOPMENT 7.1.3 Running State The activity in a running state is the one that is currently on the screen and interacting with the user. We also say this activity is in focus, meaning that all user interactionssuch as typing, touching the screen, and clicking buttonsare handled by this one activity. As such, there is only one running activity at any given time. The running activity is the one that has priority in terms of getting the memory and resources it needs to run as quickly as possible. This is because Android wants to make sure the running activity is zippy and responsive to the user. 7.1.4 Paused State When an activity is not in focus (i.e., not interacting with the user) but still visible on the screen, we say its in a paused state. This is not a typical scenario, because the devices screen is usually small, and an activity is either taking up the whole screen or none at all. We often see this case with dialog boxes that come up in front of an activity, causing it to become Paused. All activities go through a paused state en route to being stopped . Paused activities still have high priority in terms of getting memory and other resources. This is because they are visible and cannot be removed from the screen without making it look very strange to the user. 7.1.5 Stop State When an activity is not visible, but still in memory, we say its in a stopped state. Stopped activity could be brought back to the front to become a Running activity again. Or, it could be destroyed and removed from memory. The system keeps activities around in a stopped state because it is likely that the user will still want to get back to those activities sometime soon, and restarting a stopped activity is far
LIFE CYCLE
37
ANDROID MOBILE APPLICATION DEVELOPMENT cheaper than starting an activity from scratch. That is because we already have all the objects loaded in memory and simply have to bring it all up to the foreground. Stopped activities can be removed from memory at any point. 7.1.6 Destroyed State A destroyed activity is no longer in memory. The Activity Manager decided that this activity is no longer needed and has removed it. Before the activity is destroyed, it can perform certain actions, such as save any unsaved information. However, theres no guarantee that your activity will be stopped prior to being destroyed. It is possible for a paused activity to be destroyed as well. For that reason, it is better to do important work, such as saving unsaved data, en route to a paused state rather than a destroyed state.
7.2
In most cases, every Android application runs in its own Linux process. This process is created for the application when some of its code needs to be run, and will remain running until it is no longer needed and the system needs to reclaim its memory for use by other applications. An important and unusual feature of Android is that an application process's lifetime is not directly controlled by the application itself. Instead, it is determined by the system through a combination of the parts of the application that the system knows are running, how important these things are to the user, and how much overall memory is available in the system. It is important that application developers understand how different application components (in particular Activity, Service, and Intent Receiver) impact the lifetime of the application's process. Not using these components correctly can result in the system killing the application's process while it is doing important work.
LIFE CYCLE
38
ANDROID MOBILE APPLICATION DEVELOPMENT A common example of a process life-cycle bug is an Intent Receiver that starts a thread when it receives an Intent in its onReceiveIntent() method, and then returns from the function. Once it returns, the system considers that Intent Receiver to be no longer active, and thus its hosting process no longer needed (unless other application components are active in it). Thus, it may kill the process at any time to reclaim memory, terminating the spawned thread that is running in it. The solution to this problem is to start a Service from the IntentReceiver, so the system knows that there is still active work being done in the process. To determine which processes should be killed when low on memory, Android places them into an "importance hierarchy" based on the components running in them and the state of those components. These are, in order of importance as follows. 7.2.1 Foreground process It is one holding an Activity at the top of the screen that the user is interacting with (its on Rsum () method has been called) or an Intent Receiver that is currently running (its onReceiveIntent () method is executing). There will only ever be a few such processes in the system, and these will only be killed as a last resort if memory is so low that not even these processes can continue to run. Generally at this point the device has reached a memory paging state, so this action is required in order to keep the user interface responsive. 7.2.2 Visible Process It is one holding an Activity that is visible to the user on-screen but not in the foreground (its onPause() method has been called). This may occur, for example, if the foreground activity has been displayed with a dialog appearance that allows the previous activity to be seen behind it. Such a process is considered extremely important and will not be killed unless doing so is required to keep all foreground processes running.
LIFE CYCLE
39
ANDROID MOBILE APPLICATION DEVELOPMENT 7.2.3 Service Process It is one holding a Service that has been started with the startService() method. Though these processes are not directly visible to the user, they are generally doing things that the user cares about (such as background mp3 playback or background network data upload or download), so the system will always keep such processes running unless there is not enough memory to retain all foreground and visible process. 7.2.4 Backgrounds Process It is one holding an Activity that is not currently visible to the user (its onStop() method has been called). These processes have no direct impact on the user experience. Provided they implement their activity life cycle correctly (see Activity for more details), the system can kill such processes at any time to reclaim memory for one of the three previous processes types. Usually there are many of these processes running, so they are kept in an LRU list to ensure the process that was most recently seen by the user is the last to be killed when running low on memory. 7.2.5 Empty Process It is one that doesn't hold any active application components. The only reason to keep such a process around is as a cache to improve startup time the next time a component of its application needs to run. As such, the system will often kill these processes in order to balance overall system resources between these empty cached processes and the underlying kernel caches.
LIFE CYCLE
40
8. CONFERENCE APPLICATION
Objective : Developing android Mobile application VLSI 2012 to schedule conference .
8.1
This application is tab based application in which there is four tab as follows. Conference Tutorials Exhibition Others
Conference Conference tab contain the Day for conference to be held. E.g. if conference of three days so it will display like Day 1,Day 2 and Day3.The Days is displayed in list following fig show the Conference tab. Data is in form of JSON Data.
CONFERENCE APPLICATION
41
ANDROID MOBILE APPLICATION DEVELOPMENT For every day the conference is divided into different time slot. User can add conference in his schedule but time should not mismatch. e.g. if user select day 1 conference time is 9-12 then he cannot add that conference in schedule which timing is 11-10. Its depends on users. All the details of conference with timing and its details are display in list. For details Activity there is also a menu by which view can be changed in list view or Expandable List. Tutorials This tab is just like Conference tab but in tutorials directly details activity will launch. Exhibition This tab provides the layout, timing for the Exhibition, as well sponsor list for that application. Other Through this tab selected schedule can be mail to delegate, its also used to know the direction of HICC
8.2
Source Code
This section is all about creating the component of application in java code and GUI design in xml. Following are the important component which is used to develop this application. Tab Custom List View Expandable List View JSON Data Object SQLite Data Base
CONFERENCE APPLICATION
42
ANDROID MOBILE APPLICATION DEVELOPMENT 8.2.3 Creating Tab Tabactivity.java public class TabActivity extends TabActivity implements OnTabChangeListener{
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.tab); TabHost t=getTabHost(); //t.setClickable(true);
TabSpec ts1=t.newTabSpec("C"); ts1.setIndicator("Conference",getResources().getDrawable(R.drawable.conference));// there we can add image for tab //ts1.setIndicator("Confrence", getResources().getDrawable(R.drawable.icon)); Intent it1=new Intent(this,ConfrenceActivity.class); ts1.setContent(it1); t.addTab(ts1);
TabSpec ts3=t.newTabSpec("E");
CONFERENCE APPLICATION
43
public void onTabChanged(String tabId) { // TODO Auto-generated method stub //Resources r =getResources(); if(tabId.equalsIgnoreCase("C")){ setTitle("Confrence"); setTitleColor(getResources().getColor(R.color.White)); } if(tabId.equalsIgnoreCase("E")){ setTitle("Exhibition"); setTitleColor(getResources().getColor(R.color.White)); } if(tabId.equalsIgnoreCase("T")){ setTitle("Tutorials"); setTitleColor(getResources().getColor(R.color.White)); } CONFERENCE APPLICATION 44
} } } Tab.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:layout_height="match_parent" android:orientation="vertical"> <TabWidget android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@android:id/tabs"></TabWidget> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@android:id/tabcontent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab1"></LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab2"></LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab3"></LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab4"></LinearLayout> </FrameLayout>
CONFERENCE APPLICATION
45
8.3
Results
8.3.1 Conference Tab
Fig 8.2(b)
CONFERENCE APPLICATION
46
Fig 8.2(d)
GUI design for fist screen of tutorials tab which is expandable list view in .xml format.
?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >
CONFERENCE APPLICATION
47
Fig 8.3(b)
8.3.3 Exhibition Tab Following image show the activity in exhibition and some event for list which is in activity.
CONFERENCE APPLICATION
48
Fig 8.4(a): Exhibition tab screen 8.4.4 Other Tab Following figure shows the tab activity results as follows.
Fig 8.4(b):
Fig 8.5(a) 49
9.1
Oracle Database Mobile Server is the best way to securely connect mobile applications to Oracle Database. It is well suited for mission critical applications or any application where high performance and reliability are required. It extends the application grid to mobile devices, allowing access to enterprise data and applications in the absence of a network connection. When a network connection is available, Oracle Database Mobile Server uses data synchronization to allow reliable and secure data exchange with a back-end Oracle Database. Oracle Database Mobile Server can manage applications, users, devices, and data on large deployments of mobile or remote devices. Also included is a suite of tools for packaging, publishing and testing applications. 9.1.1 Key Feature Secure, efficient, resilient mobile data synchronization with Oracle Database Remote application, user and device management Standards-based encryption for remote data, in both storage and transit Robust and reliable mobile data synchronization over unreliable networks
ANDROID MOBILE APPLICATION DEVELOPMENT Highly scalable server configuration, supporting large and growing mobile or remote deployments Some new feature is added in Oracle Mobile Server like automatic Sync for android and blackberry, and Device Management for Android . 9.1.2 Components 1. The Mobile server, which includes the sync engine and the Mobile Manager. These are middle-tier infrastructure, capable of running on either Oracle Web Logic Server or Oracle Glassfish. They provide scalable, secure management of data, applications and devices. 2. Mobile Development Kit (MDK), are a suite of tools for packaging, publishing and testing application. 3. The Mobile client, which resides on mobile platform to facilitate sync and remote management. There are mobile clients available for many different platforms, including: Java, Android, Blackberry, both desktop and mobile Windows, and Linux. Following figure show components of Oracle mobile server
ANDROID MOBILE APPLICATION DEVELOPMENT 9.1.3 Architecture Following picture show how oracle mobile server connect to client and back end database .
Fig 9.2: Mobile Server with oracle data base A background process called the Message Generator and Processor (MGP), which runs in the same tier as the mobile server, periodically collects all the uploaded changes from many mobile users and then applies them to the server database. Next, MGP prepares changes that need to be sent to each mobile user. This step is essential because the next time the mobile user synchronizes with the mobile server, these changes can be downloaded to the client and applied to the client database.
9.2
Android has preinstalled SQLite data base So here SQLite mobile client is act for android mobile client. The Mobile client, which resides on mobile platform to facilitate sync and remote management. There are mobile clients available for many different platforms, including: Java, Android, Blackberry, both desktop and mobile Windows, and Linux.
ANDROID MOBILE APPLICATION DEVELOPMENT Here SQLite Mobile Client is referred to any client application which communicates with the server implicitly using the Client Side APIS. In case of Android handset, the application is to be developed and internal communication should be handled using APIS. 9.2.1 Components 1. Sync EngineEnables manual or automatic synchronization. Manual
synchronization is initiated by the mobile application. Automatic synchronization can be enabled only on the Win32, WinCE, and Linux platforms. The Sync Engine interacts with the SQLite database to upload and download data in conjunction with the Mobile Server to synchronize the data with the Oracle database. 2. Device Manager Agent (DM Agent)The DM Agent is only installed on Win32, WinCE, and Linux. The Mobile Server uses the DM Agent to send commands to the device and manage the mobile device. The Blackberry and Android platforms cannot be managed by the Mobile Server, so the DM Agent is not installed on these devices. 3. Mobile applicationInteracts with the SQLite database to manage the data. Interacts with the Sync Engine to initiate a manual synchronization. 9.2.2 Architecture
ANDROID MOBILE APPLICATION DEVELOPMENT Following picture show the data synchronization architecture
Fig 9.4: Data Sync Architecture 9.2.3 Process of Data Sync 1. Synchronization is initiated on the Mobile client either by the user or from automatic synchronization. Automatic and manual Sync for platform is shown in following table.
Platform Android Blackberry Win32 WinCE Linux Automatic synchronization Yes Yes Yes Yes Yes Device management through the DM Agent Yes No Yes Yes Yes
Table 9.1: Platform restriction for Sync 2. Mobile client software gathers all of the client changes into a transaction and the Sync Client uploads the transaction to the Sync Server on the Mobile Server. 3. Sync Server places the transaction into the In-Queue. 4. Sync Server gathers all transactions destined for the Mobile client from the OutQueue. ORACLE TO SQLITE (ANDROID) SYNCHRONIZATION 54
ANDROID MOBILE APPLICATION DEVELOPMENT 5. Sync Client downloads all changes for client database. 6. Mobile client applies all changes for client database. For Android Mobile clients, if this is the first synchronization, the SQLite database is created. 7. All transactions uploaded by all Mobile clients are gathered by the MGP out of the InQueue. 8. The MGP executes the apply phase by applying all transactions for the Mobile clients to their respective application tables to the back-end Oracle database. The MGP commits after processing each publication. 9. MGP executes the compose phase by gathering the client data into outgoing transactions for Mobile clients. 10. MGP places the composed data for Mobile clients into the Out-Queue, waiting for the next client synchronization for the Sync Server to gather the updates to the client.
9.3
Results
Fig 9.5(b):
Fig 9.5(c)
Fig 9.5(d)
Fig 9.5(e)
10.
CONCLUSION
This project deals with Android Application and Database Synchronization. Which includes application developed using Android SDK and Java Platform. The report in brief describes about installation, User Interface Oracle to SQLite Synchronization and VLSI conference as an application. Android is a truly open, free development platform based on Linux and open source. Handset makers can use and customize the platform without paying a royalty. A component-based architecture inspired by Internet mash-ups. Parts of one application can be used in another in ways not originally envisioned by the developer. can even replace built-in components with own improved versions. This will unleash a new round of creativity in the mobile space.
CONCLUSION
57
REFERENCES
1. http://www.spectrumdt.com
2. http://code.google.com/android/ - Google Android official webpage 3. http://www.openhandsetalliance.com/ - Open Handset Alliance webpage 4. http://en.wikipedia.org/wiki/Android_(mobile_phone_platform)Wikipedia information 5. http://googleblog.blogspot.com/ - Official Google Blog 6. http://www.scribed.com/- - web site for report and ppt.
VI
GLOSSARY
SDK - Software Development Kit APIs - Application Program Interfaces GUI - Graphical User Interface OHA - Open Handset Alliance GPS Global Positioning system LRU Last Recently Used MHTML Mobile HTML QoS Quality of Service WAP Web Application Protocol
VII