Programming Mobile Applications with Android

Slides:



Advertisements
Similar presentations
Programming Mobile Applications with Android
Advertisements

Unlocking Android Chapter 4.  Understanding activities and views  Exploring the Activity lifecycle  Working with resources  Defining the AndroidManifest.xml.
Android 02: Activities David Meredith
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
The Android Activity Lifecycle. Slide 2 Introduction Working with the Android logging system Rotation and multiple layouts Understanding the Android activity.
More on User Interface Android Applications. Layouts Linear Layout Relative Layout Table Layout Grid View Tab Layout List View.
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Chapter 3 Navigating a Project Goals & Objectives 1.Get familiar with the navigation of the project. How is everything structured? What settings can you.
Android: versions Note that: Honeycomb (Android v3.0) A tablet-only release Jelly Bean (Android v4.1) Released on July 09, 2012.
CS5103 Software Engineering Lecture 08 Android Development II.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Android Mobile computing for the rest of us.* *Prepare to be sued by Apple.
Android Info mostly based on Pro Android 3.  User Applications  Java Libraries – most of Java standard edition ◦ Activities/Services ◦ UI/Graphics/View.
Chapter 2: Simplify! The Android User Interface
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
DUE Hello World on the Android Platform.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml.
Android Boot Camp for Developers Using Java, 3E
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Noname. Conceptual Parts States of Activities Active Pause Stop Inactive.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
Android Application Lifecycle and Menus
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 2: Simplify! The Android User Interface
Introduction to android
Android Application -Architecture.
Chapter 2: The Visual Studio .NET Development Environment
Open Handset Alliance.
Mobile Application Development BSCS-7 Lecture # 2
Activity and Fragment.
Basic Activities and Intents
Android Boot Camp for Developers Using Java, 3E
Activities, Fragments, and Events
Fragment ?.
Mobile Application Development BSCS-7 Lecture # 6
Mobile Applications (Android Programming)
Activities and Intents
Android Activities An application can have one or more activities, where Each activity Represents a screen that an app present to its user Extends the.
Android Mobile Application Development
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
1. Introduction to Visual Basic
The Android Activity Lifecycle
ANDROID UI – FRAGMENTS UNIT II.
Chap 7. Building Java Graphical User Interfaces
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
CS5103 Software Engineering
CIS 470 Mobile App Development
Activity Lifecycle Fall 2012 CS2302: Programming Principles.
Cannon Game App Android How to Program
Android Topics Android Activity Lifecycle and Experiment Toast
Activities and Intents
HNDIT2417 Mobile Application Development
Android Programming Tutorial
CIS 470 Mobile App Development
Activity Lifecycle.
Constructors, GUI’s(Using Swing) and ActionListner
Activities and Intents
Objects First with Java
Activities and Intents
SE4S701 Mobile Application Development
Android Development Tools
Activities, Fragments, and Intents
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Programming Mobile Applications with Android 22-26 September, Albacete, Spain Jesus Martínez-Gómez

Programming Mobile Applications with Android Lesson 2.- Android basics Elements of an Android project.- Source code, layouts, and resources files. Android applications life cycle.- How Android applications are managed in our mobiles devices? Activities.- What are they used for? Views.- What are they used for? Android Lab II.- Create, compile and execute an application to understand the android life cycle. OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Lesson 2.- Android basics In this lesson, we will learn: What are the basic elements of any android project The life-cycle of the android applications What are the basic of the activities and the views We will create our first non-basic application OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Elements of an Android project.- Source code, layouts, and resources files. The last day, we introduced some of the elements of any android project. Today, we will describe them more concretely It is very important to maintain our project structured OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Elements of an Android project.- Source code. All the java classes or interfaces are stored in the src/ folder. Java classes are devoted to the development of components: Activities Main android activity that is associated to the behavior of an interface Views Basic interface elements such as Buttons, Text field, etc OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Elements of an Android project.- Source code. Services Components without an associated GUI Widgets Complex types that include both GUI and behavior The source code of our first application consists of just an activity class. Views, Services and Widgets are not so common OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Elements of an Android project.- Layouts. Are stored as xml files in the /res/layout folder Are defined in a hierarchical way A layout can contain Basic interface elements Other layouts Basic layout types FrameLayout,Gallery, GridView, LinearLayout, ListView, RelativeLayout The type of layout defines the visualization of the elements added to the layout OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Elements of an Android project.- Resource Files. Are stored in the res/ folder Several objectives and allows applications to be customized for different purposes Main resources files Layouts Text Images Menus Animations OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Elements of an Android project.- Resource Files. The resources stored in the res/ folder can be accessed both in the layout and source code files to: Establish the text for a title Establish the background image/sound for an applications Thanks to the use of different resource files, we can release the same application with different language interfaces OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android applications life cycle.- How Android applications are managed in our mobiles devices? The life cycle of Android applications is a key issue Several peculiarities An incorrect behavior of an application will affect the performance of the mobile device and would result in removing Some basics An application consists of a set of activities When an application is launched, its main activity moves to the top OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android applications life cycle.- How Android applications are managed in our mobiles devices? The Android operative system can directly stop or kill activities if resources are needed … but most of these modification are performed by the user (back button, launching other applications, etc) There are some methods that are invoked each time the life cycle of the activity changes OnCreate(), OnResume(), etc OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android activities.- What are they used for? Each activity is used to manage the behavior of an graphical user interface There are some basic that we need to start knowing Basic Activities Methods. Actions that can be done. How to start/stop other activities. How to send information between activities. OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android activities.- What are they used for? The basic methods are onCreate() onStart() onResume() onPause() onRestart() onStop() onDestroy() OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android activities.- What are they used for? onCreate() This method is called when the activity starts It should establish the content view Associate the visualization of the activy with a layout file Some basic actions Get the reference of the elements of the interface for its manipulation Set the events that will manage the user actions OnRestart() If the activity has been stopped and started again, this method is automatically called OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android activities.- What are they used for? onStart() Called when the activity is visible to the user onStop() Called when the activity has been stopped, but can be restarted after onDestroy() Called if the activity has been definitely destroyed OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android activities.- What are they used for? Activities can be started from the code using Intents These elements are used to represent the information shared between two activities Basic use Intent i = new Intent(this, nameOfNewActivity.class) startActivity(i) Send information between activities Example: activity A contains a password field and a button, when the button is pressed, the value of the password inserted is sent to the activity B that checks it OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android activities.- What are they used for? Sending information between activities Activity A (method called when the button is pressed) Intent i = new Intent(this, nameOfActivityB.class) i.putExtra(“password”,passField.getText().toString()) startActivity(i) Activity B (method onCreate) Bundle bundle = getIntent.getExtras() if(bundle.getString(“password”).equals(“TEMPUS”)) Toast.makeText(this ,"The password is OK",Toast.LENGTH_LONG) .show(); OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android views.- What are they used for? All the elements that can be added to a layout field are android Views We can use the standard elements Button ImageButton TextArea Labels .. or create our specific elements OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android views.- What are they used for? We should create a new View only when none of the basis elements does not fit our requirements We will create a new class that extends the View class import android.view.*; It should be defined a constructor public NameOfTheClass(Context context, AttributeSet attrs) { super(context, attrs); } Main method for visualization public void onDraw(Canvas canvas) OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android views.- What are they used for? Example of use import android.content.Context; import android.util.AttributeSet; import android.graphics.*; import android.view.*; public class ExampleView extends View { public ExampleView(Context context, AttributeSet attrs) { super(context, attrs); } Paint paint = new Paint(); public void onDraw(Canvas canvas) { paint.setColor(Color.BLACK); canvas.drawRect(0, 0, 250, 250, paint); paint.setColor(Color.WHITE); canvas.drawLine(10,10,240,240, paint); } } OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android views.- What are they used for? Once the view has been created, we can now add ExampleView elements in our layouts In the palette, open the Custom and library Views section We can combine both standard and custom view elements OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android views.- What are they used for? OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android views.- What are they used for? OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android Android Lab II.- Create, compile and execute an Android application to understand the Android life cycle Follow the instructions to add information messages that will be shown in the different stages of the life cycle of our application We also create a View class to include it in our layout OSSCOM Programming Mobile Applications with Android

Programming Mobile Applications with Android 22-26 September, Albacete, Spain Jesus Martínez-Gómez OSSCOM Programming Mobile Applications with Android