CSE476 Mobile Application Development. Yard. Doç. Dr. Tacha Serif Department of Computer Engineering Yeditepe University - PDF

Description
CSE476 Mobile Application Development Yard. Doç. Dr. Tacha Serif Department of Computer Engineering Yeditepe University Fall 2012 Yeditepe University 2012 Android CSE476 Mobile

Please download to get full document.

View again

of 13
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information
Category:

Small Business & Entrepreneurship

Publish on:

Views: 16 | Pages: 13

Extension: PDF | Download: 0

Share
Transcript
CSE476 Mobile Application Development Yard. Doç. Dr. Tacha Serif Department of Computer Engineering Yeditepe University Fall 2012 Yeditepe University 2012 Android CSE476 Mobile Application Development Yeditepe University Page 2 1 What is Android Android is an operating system for mobile devices such as smartphones and tablet computers. It is developed by the Open Handset Alliance led by Google. Google purchased the initial developer of the software, Android Inc., in The unveiling of the Android distribution on November 5, Android consists of a kernel based on the Linux kernel, with middleware, libraries and APIs written in C. Android uses the Dalvik virtual machine with just-in-time compilation to run compiled Java code. CSE476 Mobile Application Development Yeditepe University Page 3 What makes Android special? A truly open, free development platform based on Linux and open source: Handset makers like it because they can use and customize the platform without paying a royalty. Developers like it because they know that the platform has legs and is not locked into any one vendor that may go under or be acquired A component-based architecture inspired by Internet mashups: Parts of one application can be used in another in ways not originally envisioned by the developer. You can even replace built-in components with your own improved versions. Lots of built-in services that can be used out of the box: Location-based services use GPS or cell tower triangulation to let you customize the user experience depending on where you are. A full-powered SQL database that lets you harness the power of local storage for occasionally connected computing and synchronization. Browser and map views can be embedded directly in your applications. CSE476 Mobile Application Development Yeditepe University Page 4 2 What makes Android special? (cont.) Automatic management of the application life cycle: Programs are isolated from each other by multiple layers of security, which will provide a level of system stability not seen before in smart phones. The end user will no longer have to worry about what applications are active or close some programs so that others can run. Android is optimized for lowpower, low-memory devices in a fundamental way that no previous platform has attempted. High-quality graphics and sound: Smooth, antialiased 2D vector graphics and animation inspired by Flash are melded with 3Daccelerated OpenGL graphics to enable new kinds of games and business applications. Portability across a wide range of current and future hardware: All your programs are written in Java and executed by Android s Dalvik virtual machine, so your code will be portable across ARM, x86, and other architectures. CSE476 Mobile Application Development Yeditepe University Page 5 Android Versions CSE476 Mobile Application Development Yeditepe University Page 6 3 Android System Architecture The Dalvik VM runs.dex files, which are converted at compile time from standard.class and.jar files..dex files are more compact and efficient than class files, an important consideration for the limited memory and battery-powered devices that Android targets. CSE476 Mobile Application Development Yeditepe University Page 7 Android Software Environment CSE476 Mobile Application Development Yeditepe University Page 8 4 Activity Lifecycle CSE476 Mobile Application Development Yeditepe University Page 9 Activity Lifecycle (Cont.) oncreate(bundle) - This is called when the activity first starts up. You can use it to perform one-time initialization such as creating the user interface. oncreate( ) takes one parameter that is either null or some state information previously saved by the onsaveinstancestate() method. onstart() - This indicates the activity is about to be displayed to the user. onresume() - This is called when your activity can start interacting with the user. This is a good place to start animations and music. onpause() - This runs when the activity is about to go into the background, usually because another activity has been launched in front of it. This is where you should save your program s persistent state, such as a database record being edited. onstop() - This is called when your activity is no longer visible to the user and it won t be needed for a while. If memory is tight, onstop( ) may never be called (the system may simply terminate your process CSE476 Mobile Application Development Yeditepe University Page 10 5 Activity Lifecycle (Cont.) onrestart() - If this method is called, it indicates your activity is being redisplayed to the user from a stopped state. ondestroy() - This is called right before your activity is destroyed. If memory is tight, ondestroy() may never be called (the system may simply terminate your process). onsaveinstancestate(bundle) - Android will call this method to allow the activity to save per-instance state, such as a cursor position within a text field. Usually you won t need to override it because the default implementation saves the state for all your user interface controls automatically. onrestoreinstancestate(bundle) - This is called when the activity is being reinitialized from a state previously saved by the onsaveinstancestate() method. The default implementation restores the state of your user interface. CSE476 Mobile Application Development Yeditepe University Page 11 Android Application Architecture Activity Manager - Controls the life cycle of your Activities, including management of the Activity. Views - Used to construct the user interfaces for your Activities. Notification Manager - Provides a consistent and nonintrusive mechanism for signaling your users. Content Providers - Let your applications share data. Resource Manager - Supports non-code resources like strings and graphics to be externalized. CSE476 Mobile Application Development Yeditepe University Page 12 6 Anatomy of an Android Project src Contains the.java source files for your project. In this example, there is one file, MainActivity.java. The MainActivity.java file is the source file for your activity. You will write the code for your application in this file. Android library This item contains one file, android.jar, which contains all the class libraries needed for an Android application. gen Contains the R.java file, a compilergenerated file that references all the resources found in your project. You should not modify this file. assets This folder contains all the assets used by your application, such as HTML, text files, databases, etc. CSE476 Mobile Application Development Yeditepe University Page 13 Anatomy of an Android Project (Cont.) res This folder contains all the resources used in your application. It also contains a few other subfolders: drawable- resolution , layout, and values. res/drawable-hdpi/icon.png, res/drawableldpi/icon.png, and res/drawable-mdpi/icon.png: Three renditions of a placeholder icon for your application for high-, low-, and mediumdensity screens, respectively res/layout/main.xml: An XML file that describes the very simple layout of your user interface res/values/strings.xml: An XML file that contains externalized strings, notably the placeholder name of your application res/drawable/: For images (PNG, JPEG, etc.) CSE476 Mobile Application Development Yeditepe University Page 14 7 Anatomy of an Android Project (Cont.) res/layout/: For XML-based UI layout specifications res/menu/: For XML-based menu specifications res/raw/: For general-purpose files (e.g., an audio clip or a CSV file of account information) res/values/: For strings, dimensions, and the like res/xml/: For other general-purpose XML files you wish to ship AndroidManifest.xml This is the manifest file for your Android application. Here you specify the permissions needed by your application, as well as other features (such as intent-filters, receivers, etc.). CSE476 Mobile Application Development Yeditepe University Page 15 Types of Android Applications Foreground: An application that s useful only when it s in the foreground and is effectively suspended when it s not visible. Games and map mash-ups are common examples. Background: An application with limited interaction that, apart from when being configured, spends most of its lifetime hidden. Examples include call screening applications and SMS autoresponders. Intermittent: Expects some interactivity but does most of its work in the background. Often these applications will be set up and then run silently, notifying users when appropriate. A common example would be a media player. Widget: Some applications are represented only as a home-screen widget. CSE476 Mobile Application Development Yeditepe University Page 16 8 Widget Types TextView Multiline, string formatting, auto word wrap EditText Multiline entry, word wrap, hints ListView Vertical list of views Spinner Text view and associated List View; select an item from a list to display in the textbox CSE476 Mobile Application Development Yeditepe University Page 17 Button CheckBox RadioButton ViewFlipper Widget Type (Cont.) Collection of views as a horizontal row where only one view is visible at a time; animated transitions QuickContactBadge Badge w/ image icon assigned to contact CSE476 Mobile Application Development Yeditepe University Page 18 9 Common Layouts FrameLayout Pins children to top left corner LinearLayout Vertical or horizontal line RelativeLayout Flexible. Define positions relative to others and screen boundaries TableLayout Grid of rows and columns Gallery Single row of items in a horizontally scrolling list CSE476 Mobile Application Development Yeditepe University Page 19 FrameLayout FrameLayout xmlns:android= http://schemas.android.com/ap k/res/android ImageView android:scaletype= fitcenter / android:text= CSE476 MAD android:textsize= 24sp android:textcolor= #000000 android:gravity= center / /FrameLayout FrameLayout is designed to display a single item at a time. You can have multiple elements within a FrameLayout but each element will be positioned based on the top left of the screen. Elements that overlap will be displayed overlapping. CSE476 Mobile Application Development Yeditepe University Page 20 10 LinearLayout ?xml version= 1.0 encoding= utf-8 ? LinearLayout xmlns:android= http://schemas.android.com/apk/res/android android:orientation= vertical LinearLayout android:orientation= horizontal android:layout_weight= 1 android:text= red android:gravity= center_horizontal android:background= #aa0000 android:layout_width= wrap_content android:text= green android:gravity= center_horizontal android:background= #00aa00 android:layout_width= wrap_content android:text= blue android:gravity= center_horizontal android:background= #0000aa android:layout_width= wrap_content android:text= yellow android:gravity= center_horizontal android:background= #aaaa00 android:layout_width= wrap_content /LinearLayout LinearLayout is a ViewGroup that displays child View elements in a linear direction, either vertically or horizontally. CSE476 Mobile Application Development Yeditepe University Page 21 LinearLayout (Cont.) LinearLayout android:orientation= vertical android:layout_weight= 1 android:text= row one android:textsize= 15pt android:text= row two android:textsize= 15pt android:text= row three android:textsize= 15pt android:text= row four android:textsize= 15pt /LinearLayout /LinearLayout LinearLayout is a ViewGroup that displays child View elements in a linear direction, either vertically or horizontally. CSE476 Mobile Application Development Yeditepe University Page 22 11 RelativeLayout ?xml version= 1.0 encoding= utf-8 ? RelativeLayout xmlns:android= http://schemas.android.com/apk/r es/android android:text= type here: / EditText ditbox_background Button android:layout_width= wrap_content android:layout_alignparentright= true android:layout_marginleft= 10dip android:text= ok / Button android:layout_width= wrap_content android:text= cancel / /RelativeLayout RelativeLayout is a ViewGroup that displays child View elements in relative positions. The position of a View can be specified as relative to sibling elements (such as to the left-of or below a given element) or in positions relative to the RelativeLayout area (such as aligned to the bottom, left of center). CSE476 Mobile Application Development Yeditepe University Page 23 TableLayout ?xml version= 1.0 encoding= utf-8 ? TableLayout xmlns:android= http://schemas.android.com/apk/res/android android:stretchcolumns= 1 TableRow android:layout_column= 1 android:text= open... android:text= ctrl-o android:gravity= right /TableRow TableRow android:layout_column= 1 android:text= save... android:text= ctrl-s android:gravity= right /TableRow TableRow android:layout_column= 1 android:text= save As... android:text= ctrl-shift-s android:gravity= right /TableRow The TableLayout element is like the HTML table element; TableRow is like a tr element; but for the cells, you can use any kind of View element. CSE476 Mobile Application Development Yeditepe University Page 24 12 TableLayout (Cont.) View android:layout_height= 2dip android:background= #ff909090 / TableRow android:text= x android:text= import... /TableRow TableRow android:text= x android:text= export... android:text= ctrl-e android:gravity= right /TableRow View android:layout_height= 2dip android:background= #ff909090 / TableRow android:layout_column= 1 android:text= quit /TableRow /TableLayout The TableLayout element is like the HTML table element; TableRow is like a tr element; but for the cells, you can use any kind of View element. CSE476 Mobile Application Development Yeditepe University Page 25 Gallery ?xml version= 1.0 encoding= utf-8 ? LinearLayout xmlns:android= http://schemas.android.com/apk/res/android android:orientation= vertical android:text= images of San Francisco / Gallery / ImageView android:layout_width= 320px android:layout_height= 250px android:scaletype= fitxy / /LinearLayout The Gallery is a view that shows items (such as images) in a center-locked, horizontal scrolling list. Shows the Gallery view used in the Android Market. CSE476 Mobile Application Development Yeditepe University Page 26 13
Related Search
Similar documents
View more...
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x