MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

Size: px
Start display at page:

Download "MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs"

Transcription

1 Overview MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs Lecture: MVC Model View Controller What is an App? Android Activity Lifecycle Android Debugging Fixing Rotations & Landscape Layouts Localization MVC Model, View, Controller Architecture Pattern Very common, many variants Concept - breakdown all objects into either: Models (data) Views (user interface) Controller (application logic) Benefits: Breaks App into manageable chunks Can swap logic, user interface, or data easily MVC - Model The Model holds application data Examples are user data, product information, questions, profile data, etc These will usually be custom classes Examples include: SQLite JSON XML 1

2 MVC - View MVC - Controller Views handle the user interface, such as drawing themselves They may also handle user input (although variations of MVC don t) If you can see it, consider it a view! Application view objects make up the view layer Our view objects are inflated from XML in the controller using setcontentview() This is the glue that binds the Model and View Contains application logic and handles the flow of information from the view to the model and back For Android, controllers usually inherit from Activity, Fragment or Service We ll talk about Fragments and Services later in the course MVC All Together Now User Input User presses something View sends message to controller View Controller Model Controller updates the view with data Controller updates model Controller takes data from model What is an App? We ve mentioned activities and apps, they are NOT the same thing The application is contained in an.apk file, and used to install onto a device Every app is isolated into it s own sandbox (linux process) and even has it s own Java virtual machine If any of an app s components are needed, the app is started and then shut down by the user or the system to recover memory 2

3 What is an App? What is an App? An App is made up of components: 1. Activities single screen with a UI suiting a single purpose 2. Services an app that runs in the background such as playing music or network activity 3. Broadcast Receivers Allows for the system to deliver events (messages) to registered apps such as low power or alarms 4. Content Providers manages an app meant to share datasets such as contacts Components (activities, services, broadcast receivers) are activated by intents An intent defines a message to activate a specific component (explicit intent) or a type of component (implicit intent) You can use intents with startactivity() or startactivityforresult() You can start service with a JobScheduler or startservice() You can broadcast with sendbroadcast() The Apps definition - Manifest Before an app starts, Android knows every component through the App s Manifest Manifest is located at the root directory, and all components must be in this file Purposes: 1. User permissions the app requires (normal & dangerous) 2. Minimum API level for the app 3. Hardware and software features used by the app 4. API libraries beyond the Android API Looks like: <activity> <services> <receiver> <provider> We will cover each if these in more detail in future lectures Lets create a new empty app Add a button to our layout from the GUI Interface, make sure it has a resource ID This looks ugly left justified, click View all properties at the bottom of the properties tab Find the property gravity and press center to align Gravity impacts how views within the view layout are arranged and placed 3

4 We don t want our button to span the entire extent of the screen Select the button and look for layout_width and layout_height Select wrap_content for layout_width Note that this property has the layout_ naming convention, this means it is instructing its container object We need a reference to the button to use it public class MainActivity extends AppCompatActivity { private TextView textview; private Button button; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); textview = (TextView)findViewById(R.id.textView); textview.settext("we are changing text!"); button = (Button)findViewById(R.id.button); Create a variable to hold a reference to the button, grab it with findviewbyid() and cast to a Button To control the button s functionality we have two options: 1. Declare a Method in our Class &/or link in xml 2. Anonymous Class Anonymous Class a one shot class that doesn t have a name, usually implements some interface (functionality) If we don t want to use an anonymous class, we can use the interface and then generate it with help from Android Studio button.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { //purposely left empty ); If we use the method approach, we can also hard-code the name into the XML This forms a connection between the button and the actual code to occur during pressing 4

5 Android Studio can do much of the work for you if you remember what you want to do and are fine with a little searching public class MainActivity extends AppCompatActivity implements View.OnClickListener{ private TextView textview; private Button button; public void onclick(view v) { //Left blank Let s randomly change the color of our Text View whenever the button is pressed, we ll use an Anonymous class for this: button.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { Random rand = new Random(); textview.settextcolor(color.argb(rand.nextint(255), rand.nextint(255), rand.nextint(255), rand.nextint(255))); ); Many of the text input widgets are just variations of how text is displayed / if a keyboard is expected to be used Add a Plain Text field to our application, make sure we have an ID Hint text is a suggestion on what to enter Input Type restricts what can be placed inside or how the field reacts Jump into code and add an Edit Text private variable How did I know what class to use? Check the XML! Grab the edit text by ID & attach a listener to work with the EditText object: addtextchangedlistener each time a field is changed setoneditoractionlistener when action button is clicked on keyboard 5

6 edittext.addtextchangedlistener(new TextWatcher() { public void beforetextchanged(charsequence s, int start, int count, int after) { public void ontextchanged(charsequence s, int start, int before, int count) { public void aftertextchanged(editable s) { ); Let s take the input after the action button is pressed and apply it to the text of our button edittext.setoneditoractionlistener(new TextView.OnEditorActionListener() { public boolean oneditoraction(textview v, int actionid, KeyEvent event) edittext.setoneditoractionlistener(new TextView.OnEditorActionListener() { public boolean oneditoraction(textview v, int actionid, KeyEvent event) { return false; ); ); { button.settext(v.gettext()); return false; Toasts If we need to temporarily inform the user about something we can use toasts Toasts don t require any user interaction, think of them as brief messages to the user Toasts The Toast class has a public static method called maketext() There are two versions of maketext: Toast.makeText( Context context, CharSequence text, int duration); This is a toast Toast.makeText( Context context, int resid, int duration); 6

7 Toasts Put a toast in the button listener: There is a problem try rotating your device edittext.setoneditoractionlistener(new TextView.OnEditorActionListener() { public boolean oneditoraction(textview v, int actionid, KeyEvent event) { button.settext(v.gettext()); Toast.makeText(MainActivity.this, "A button has been pressed.", Toast.LENGTH_LONG).show(); Notice how everything resets? Your app was created and destroyed. return false; Android Activity Lifecycle Android Activity Lifecycle The lifecycle of an activity goes through several stages This diagram shows the possible states of your activity When states are changed, methods are automatically called by the Activity Manager The oncreate method starts up the activity, it is called before it become visible to the user We can cause lifecycle changes easily: Home button I m going to do something else for a moment but I will come back to the activity Back button I m done with this activity 7

8 Android Activity Lifecycle Android Debugging We are going to use android.util.log class to understand activity state changes The log has multiple levels for filtering: use d for debug Log methods use two strings, a TAG meant to identify the source class and the MESSAGE (a string or a resource can be used) Methods of Debugging: LogCat & Dalvik Debug Monitor Service (DDMS) Breakpoints & Debug Perspective Android Lint It is highly recommended to create a private static final String for each class to uniquely identify messages: private static final String TAG = LifecycleTest ; Android Debugging LogCat and DDMS You can see Log Cat in 2 ways: Android Debugging LogCat and DDMS LogCat has 5 log levels 1. Error: Log.e( ) Errors 2. Warning: Log.w( ) Warnings 3. Info: Log.i( ) Information 4. Debug: Log.d( ) Debug output 5. Verbose: Log.v( ) Dev only! Verbose Debug Information Warning Error 8

9 Android Debugging LogCat and DDMS Filters can be used to view by Package Name, Tag or content (this is important since your phone will be spitting out tons of data) Click the green + button Android Debugging LogCat, DDMS,Debug Dalvik Debug Monitor Service (DDMS) handles debugging We can also access the debug menu to see application information Android Debugging LogCat and DDMS To add a break point, click in the grey space near the left side of your code Swap to the debug perspective in the device manager You need to debug the app, not run the app Android Debugging Android Lint Lint saves you on Android (not java) specific problems Issues with XML, versions, resource IDs, etc Every once and a while, lint and auto-complete will fail miserably, restart Android Studio Use the resume, disconnect, step over, return Use variables and breakpoints tab to find things quickly 9

10 Device Configurations When the device is rotated, the device configuration is changed Configurations are composed of: Screen Orientation Screen Density Screen Size Keyboard Type Dock Mode Language And more Screen Orientation change the device config Multiple Layouts Create a new folder under res called: layout-land Or, in the Design panel for the layout: Design panel s Create Landscape Variant will make a new version with all the same widgets and Ids Multiple Layouts Both layouts need the same filename for this to work (they get assigned the same resource) *layoutname*-land is a configuration qualifier so Android can figure out what layout to use based on the device Multiple Layouts We will cover how to save data in another lecture. There are multiple means: Bundles Files / Databases JSON / XML 10

11 Localization Localization Android devices are used worldwide Localization the process of providing the appropriate resources for your app based on the device s language settings Customization of your app to handle various locales and spoken languages increases the number of potential customers Localization can be for any resource, we will be focusing on text Language settings are part of the device s configuration Localization is handled through configuration qualifiers You create folders within res with names specific to the language you are supporting Folders with no qualifier ( the ones you normally see) will be the default when no folder is found for the current settings Localization Android Studio features an easy way: Localization Setup Folders Config qualifiers for folders come from ISO codes: French and Spanish values can be supported by creating the following folders under res values-fr raw-fr values-es raw-es Regional differences can also be supported: values-en-rus values-en-rgb 11

12 Localization Setup Folders Localization Setup Folders Use a translator to create some basic text across English, French and Spanish To see the changes on your device, you ll need to set the language in Settings->Personal->Language & input Create your strings in your native language in a strings.xml file Copy and paste this file into the other language folders or let Android Studio do it for you Paste in your translated text for each Localization Setup Folders Localization A Note on Configuration Qualifiers You may feel tempted to throw all your resources is a folder specifically for English DON T DO THIS! You need a default directory, otherwise a qualifier can t be found, it will crash the application Keep your native language in default, because displaying something is always better than a crashed app! There is a hierarchy of configuration qualifiers used by android to determine what resources to use: 1. Mobile Country Code 2. Language Code 3. Layout Direction 4. Smallest Width 5. Available Width 6. Available Height 7. Screen Size

13 Localization A Note on Configuration Qualifiers Homework Android determines the resources to use by REMOVING resources that don t meet the needs of the configuration first It steps down the hierarchy and remove those that don t fulfill the current level When one configuration is left, it uses that one (which very well might be the default) You can have multiple qualifiers on a folder: values es land (Spanish language with landscape) Note that the order must follow the hierarchy! Create an app that: 1. Logs debug information for each of the Activity lifecycle changes 2. Features a button and input text field 3. Uses a toast 4. Has a separate layout for vertical and horizontal layours 5. Features 1 other language Dialogs Small window that does not fill the entire screen prompting the user to make a decision We use one of the provided classes: AlertDialog title, three buttons, selectable items, custom layout DatePickerDialog/TimerPickerDialog predefined UI to selected date/time ProgressDialog - deprecated Android recommends using a DialogFragment to contain the Dialog, but we haven t learned fragments yet so ignore for now. Alert Dialogs Alert Dialogs are modal dialogs, a subset that allow for up to 3 buttons of input from the user They block interaction with the application until the user performs some function They are capable of displaying: Negative Action Pressing Cancel / No Positive Action Pressing OK / Yes Neutral Action Do not continue, ignore! Extended Alert Dialogs can feature views such as: Buttons Checkboxes Radio buttons Lists of items 13

14 Alert Dialogs The parts of an Alert Dialog: 1. Title Optional, only necessary when content area is complex 2. Content Area A message, list or custom layout 3. Action Button Up to three action buttons setpositivebutton() setnegativebutton() setneutralbutton() Alert Dialogs Steps to create an Alert Dialog: 1. Instantiate an AlertDialog.Builder() 2. Chain setter methods: Setting the message/title and buttons Creating any listeners to the buttons 3. Create the AlertDialog from the builder 4. Show the AlertDialog Alert Dialogs Alert Dialogs Returning Information button.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setmessage("this is the message"); builder.settitle("this is the title"); builder.setpositivebutton("positive button pressed", null); builder.setnegativebutton("negative button pressed", new DialogInterface.OnClickListener() { public void onclick(dialoginterface dialog, int which) { Toast.makeText(MainActivity.this, "Example text", Toast.LENGTH_SHORT); ); builder.setneutralbutton("neutral Button", null); ); AlertDialog dialog = builder.create(); dialog.show(); Since we are dealing with a nested class, we have access to our parent Create methods in the parent class to handle each Alert Dialog case protected void onpositivepress() { textview.settext("positive Press"); protected void onnegativepress() { textview.settext("negative Press"); protected void onneutralpress() { textview.settext("neutral Press"); 14

15 Alert Dialogs Adding a List Available List Types: 1. Single-choice list 2. Persistent single-choice list (radio buttons) 3. Persistent multiple-choice list (checkboxes) Lists require usage of the setitems() method, a list of objects and a callback to handle selection The list is stored in the message area, so the title bar should be used to communicate to the user Alert Dialogs Adding a List Available List Types: 1. Single-choice list 2. Persistent single-choice list (radio buttons) 3. Persistent multiple-choice list (checkboxes) Lists require usage of the setitems() method, a list of objects and a callback to handle selection The list is stored in the message area, the title bar is used to communicate to the user In the future we will discuss adding ArrayAdapters for dynamic data Alert Dialogs Adding a List AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.settitle("list Example").setItems(R.array.faculty_names, new DialogInterface.OnClickListener() { public void onclick(dialoginterface dialog, int which) { switch(which) { case 0: textview.settext("polikar"); break; case 1: textview.settext("schmalzel"); break; case 2: textview.settext("krchnavek"); break; case 3: textview.settext("head"); break; ).create().show(); Alert Dialogs Adding a List We can create a custom layout for our dialog, in addition to the buttons that a normal layout would have Create a new custom layout however you see fit public void onclick(view v) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setview(r.layout.dialog_test).setpositivebutton("ok", new DialogInterface.OnClickListener() { public void onclick(dialoginterface dialog, int which) { ).setnegativebutton("cancel", new DialogInterface.OnClickListener() { public void onclick(dialoginterface dialog, int which) { ).create(); builder.show(); 15

16 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" xmlns:app=" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:adjustviewbounds="true" android:scaletype="fitxy" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:fontfamily="cursive" android:gravity="center" android:paddingbottom="20sp" android:text="love Craft" android:textsize="36sp" android:textstyle="bold" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:adjustviewbounds="true" android:croptopadding="true" android:scaletype="fitxy" /> </LinearLayout> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:gravity="center" android:hint="user Name" android:inputtype="textpersonname" android:text="name" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:gravity="center" android:hint="password" android:inputtype="textpassword" /> </LinearLayout> Android Activity Lifecycle Mini Lab (25 minutes) 1. Create a new activity called LifecycleTest 2. Override the following methods: public void onstart() public void onpause() public void onresume() public void onstop() public void ondestroy() 3. Add a static string for the tag 4. Add a Log.d() to each method telling when the method is executed 5. Make sure you call the super class methods FIRST! 6. Press Home then press Back 16

Orientation & Localization

Orientation & Localization Orientation & Localization Overview Lecture: Open Up Your My Pet App Handling Rotations Serializable Landscape Layouts Localization Alert Dialogs 1 Handling Rotations When the device is rotated, the device

More information

INTRODUCTION TO ANDROID

INTRODUCTION TO ANDROID INTRODUCTION TO ANDROID 1 Niv Voskoboynik Ben-Gurion University Electrical and Computer Engineering Advanced computer lab 2015 2 Contents Introduction Prior learning Download and install Thread Android

More information

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml Android Application Written in Java (it s possible to write native code) Good

More information

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L 2 0 1 5 Activity Basics Manifest File AndroidManifest.xml Central configuration of Android application Defines: Name of application Icon for

More information

Android UI Development

Android UI Development Android UI Development Android UI Studio Widget Layout Android UI 1 Building Applications A typical application will include: Activities - MainActivity as your entry point - Possibly other activities (corresponding

More information

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu Android Activity LifeCycle Starting Activities Android applications don't start with a call to main(string[])

More information

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University. Creating dialogs Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University. Portions of this page are reproduced from work created and

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are

More information

Lab 1 - Setting up the User s Profile UI

Lab 1 - Setting up the User s Profile UI Lab 1 - Setting up the User s Profile UI Getting started This is the first in a series of labs that allow you to develop the MyRuns App. The goal of the app is to capture and display (using maps) walks

More information

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based

More information

CS378 -Mobile Computing. Anatomy of and Android App and the App Lifecycle

CS378 -Mobile Computing. Anatomy of and Android App and the App Lifecycle CS378 -Mobile Computing Anatomy of and Android App and the App Lifecycle Hello Android Tutorial http://developer.android.com/resources/tutorials/hello-world.html Important Files src/helloandroid.java Activity

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 2 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 1 -recap What is Android How to develop Android applications Run & debug the applications

More information

Android Basics. Android UI Architecture. Android UI 1

Android Basics. Android UI Architecture. Android UI 1 Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à

More information

Mobile User Interfaces

Mobile User Interfaces Mobile User Interfaces CS 2046 Mobile Application Development Fall 2010 Announcements Next class = Lab session: Upson B7 Office Hours (starting 10/25): Me: MW 1:15-2:15 PM, Upson 360 Jae (TA): F 11:00

More information

Fragments. Lecture 11

Fragments. Lecture 11 Fragments Lecture 11 Situational layouts Your app can use different layouts in different situations Different device type (tablet vs. phone vs. watch) Different screen size Different orientation (portrait

More information

Android Application Development

Android Application Development Android Application Development Octav Chipara What is Android A free, open source mobile platform A Linux-based, multiprocess, multithreaded OS Android is not a device or a product It s not even limited

More information

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial Hello World Lesson 1 This work is licensed This under work a Creative is is licensed Commons under a a Attribution-NonCommercial Creative 4.0 Commons International Attribution- License 1 NonCommercial

More information

Our First Android Application

Our First Android Application Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,

More information

CS 4330/5390: Mobile Application Development Exam 1

CS 4330/5390: Mobile Application Development Exam 1 1 Spring 2017 (Thursday, March 9) Name: CS 4330/5390: Mobile Application Development Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and closed-book.

More information

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment FRAGMENTS Fragments An activity is a container for views When you have a larger screen device than a phone like a tablet it can look too simple to use phone interface here. Fragments Mini-activities, each

More information

UNDERSTANDING ACTIVITIES

UNDERSTANDING ACTIVITIES Activities Activity is a window that contains the user interface of your application. An Android activity is both a unit of user interaction - typically filling the whole screen of an Android mobile device

More information

Android for Ubiquitous Computing Researchers. Andrew Rice University of Cambridge 17-Sep-2011

Android for Ubiquitous Computing Researchers. Andrew Rice University of Cambridge 17-Sep-2011 Android for Ubiquitous Computing Researchers Andrew Rice University of Cambridge 17-Sep-2011 Getting started Website for the tutorial: http://www.cl.cam.ac.uk/~acr31/ubicomp/ Contains links to downloads

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu Administrivia Moved back deadlines for projects 2, 3 and final project See updated schedule

More information

Lab Android Development Environment

Lab Android Development Environment Lab Android Development Environment Setting up the ADT, Creating, Running and Debugging Your First Application Objectives: Familiarize yourself with the Android Development Environment Important Note:

More information

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Gill Cleeren Agenda Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Lists and navigation Navigating from master to detail Optimizing the application Preparing

More information

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Activity Logging Lecture 16

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Activity Logging Lecture 16 Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Activity Logging Lecture 16 Hello, last two classes we learned about activity life cycles and the call back

More information

Vienos veiklos būsena. Theory

Vienos veiklos būsena. Theory Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is

More information

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters Mobile Programming Lecture 5 Composite Views, Activities, Intents and Filters Lecture 4 Review How do you get the value of a string in the strings.xml file? What are the steps to populate a Spinner or

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should

More information

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling Lecture 1 Review How to edit XML files in Android Studio? What holds all elements (Views) that appear to the user in an Activity?

More information

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time The 1 activity 1 thing the user can do heuristic may not make sense for larger devices Application

More information

07. Menu and Dialog Box. DKU-MUST Mobile ICT Education Center

07. Menu and Dialog Box. DKU-MUST Mobile ICT Education Center 07. Menu and Dialog Box DKU-MUST Mobile ICT Education Center Goal Learn how to create and use the Menu. Learn how to use Toast. Learn how to use the dialog box. Page 2 1. Menu Menu Overview Menu provides

More information

Chapter 2 Welcome App

Chapter 2 Welcome App 2.8 Internationalizing Your App 1 Chapter 2 Welcome App 2.1 Introduction a. Android Studio s layout editor enables you to build GUIs using drag-and-drop techniques. b. You can edit the GUI s XML directly.

More information

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering Getting Started Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador 1 Goals Setting up your development environment Android Framework

More information

Introduction to Android

Introduction to Android Introduction to Android Ambient intelligence Teodoro Montanaro Politecnico di Torino, 2016/2017 Disclaimer This is only a fast introduction: It is not complete (only scrapes the surface) Only superficial

More information

EMBEDDED SYSTEMS PROGRAMMING Application Basics

EMBEDDED SYSTEMS PROGRAMMING Application Basics EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Basics APPLICATIONS Application components (e.g., UI elements) are objects instantiated from the platform s frameworks Applications are event driven ( there

More information

Android Programming Lecture 2 9/7/2011

Android Programming Lecture 2 9/7/2011 Android Programming Lecture 2 9/7/2011 Creating a first app 1. Create a new Android project (a collection of source code and resources for the app) from the Eclipse file menu 2. Choose a project name (can

More information

Activities and Fragments

Activities and Fragments Activities and Fragments 21 November 2017 Lecture 5 21 Nov 2017 SE 435: Development in the Android Environment 1 Topics for Today Activities UI Design and handlers Fragments Source: developer.android.com

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu Announcements Group formation: Projects 2, 3 and final project will be

More information

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. User Interface Development CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. Rajiv Ramnath 1 Outline UI Support in Android Fragments 2 UI Support in the Android

More information

Text Properties Data Validation Styles/Themes Material Design

Text Properties Data Validation Styles/Themes Material Design Text Properties Data Validation Styles/Themes Material Design Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: Email:info@sisoft.in Phone: +91-9999-283-283

More information

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are:

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are: ETSN05, Fall 2017, Version 1.0 Software Development of Large Systems Lab 2 preparations Read through this document carefully. In order to pass lab 2, you will need to understand the topics presented in

More information

Lifecycle Callbacks and Intents

Lifecycle Callbacks and Intents SE 435: Development in the Android Environment Recitations 2 3 Semester 1 5779 4 Dec - 11 Dec 2018 Lifecycle Callbacks and Intents In this recitation we ll prepare a mockup tool which demonstrates the

More information

CMSC436: Fall 2013 Week 3 Lab

CMSC436: Fall 2013 Week 3 Lab CMSC436: Fall 2013 Week 3 Lab Objectives: Familiarize yourself with the Activity class, the Activity lifecycle, and the Android reconfiguration process. Create and monitor a simple application to observe

More information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi Introduction An application is composed of at least one Activity GUI It is a software component that stays behind a GUI (screen) Activity It runs inside the

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Android Lifecycle An activity begins its lifecycle when entering the oncreate() state If not

More information

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license Android Android Mobile operating system developed by Google A complete stack OS, framework A rich set of applications Email, calendar, browser, maps, text messaging, contacts, camera, dialer, music player,

More information

CS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle

CS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle Application Components five primary components different purposes and different lifecycles Activity single screen with a user interface,

More information

Fragments. Lecture 10

Fragments. Lecture 10 Fragments Lecture 10 Situa2onal layouts Your app can use different layouts in different situa2ons Different device type (tablet vs. phone vs. watch) Different screen size Different orienta2on (portrait

More information

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard. 44 CHAPTER 2 Android s development environment Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard. TIP You ll want the package name of your applications to be unique

More information

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2 Workshop 1. Compare different layout by using Change Layout button (Page 1 5) Relative Layout Linear Layout (Horizontal) Linear Layout (Vertical) Frame Layout 2. Revision on basic programming skill - control

More information

More Effective Layouts

More Effective Layouts More Effective Layouts In past weeks, we've looked at ways to make more effective use of the presented display (e.g. elastic layouts, and separate layouts for portrait and landscape), as well as autogenerating

More information

Mobile Computing Fragments

Mobile Computing Fragments Fragments APM@FEUP 1 Fragments (1) Activities are used to define a full screen interface and its functionality That s right for small screen devices (smartphones) In bigger devices we can have more interface

More information

Upon completion of the second part of the lab the students will have:

Upon completion of the second part of the lab the students will have: ETSN05, Fall 2017, Version 2.0 Software Development of Large Systems Lab 2 1. INTRODUCTION The goal of lab 2 is to introduce students to the basics of Android development and help them to create a starting

More information

UI Fragment.

UI Fragment. UI Fragment 1 Contents Fragments Overviews Lifecycle of Fragments Creating Fragments Fragment Manager and Transactions Adding Fragment to Activity Fragment-to-Fragment Communication Fragment SubClasses

More information

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android.

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android. Q.1 Explain the dialog and also explain the Demonstrate working dialog in android. - A dialog is a small window that prompts the user to make a decision or enter additional information. - A dialog does

More information

Embedded Systems Programming - PA8001

Embedded Systems Programming - PA8001 Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 9 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering

More information

Arrays of Buttons. Inside Android

Arrays of Buttons. Inside Android Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.

More information

Programming in Android. Nick Bopp

Programming in Android. Nick Bopp Programming in Android Nick Bopp nbopp@usc.edu Types of Classes Activity This is the main Android class that you will be using. These are actively displayed on the screen and allow for user interaction.

More information

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input 1 UI Components 2 UI Components 3 A label is called a TextView. TextView TextViews are typically used to display a caption TextViews are not editable, therefore they take no input - - - - - - -

More information

Basic GUI elements - exercises

Basic GUI elements - exercises Basic GUI elements - exercises https://developer.android.com/studio/index.html LIVE DEMO Please create a simple application, which will be used to calculate the area of basic geometric figures. To add

More information

Android Fundamentals - Part 1

Android Fundamentals - Part 1 Android Fundamentals - Part 1 Alexander Nelson September 1, 2017 University of Arkansas - Department of Computer Science and Computer Engineering Reminders Projects Project 1 due Wednesday, September 13th

More information

ANDROID USER INTERFACE

ANDROID USER INTERFACE 1 ANDROID USER INTERFACE Views FUNDAMENTAL UI DESIGN Visual interface element (controls or widgets) ViewGroup Contains multiple widgets. Layouts inherit the ViewGroup class Activities Screen being displayed

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Entire Lifetime An activity begins its lifecycle when entering the oncreate() state If not interrupted

More information

Solving an Android Threading Problem

Solving an Android Threading Problem Home Java News Brief Archive OCI Educational Services Solving an Android Threading Problem Introduction by Eric M. Burke, Principal Software Engineer Object Computing, Inc. (OCI) By now, you probably know

More information

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Software Practice 3 Before we start Today s lecture Today s Task Team organization 1 Software Practice 3 Before we start Today s lecture Today s Task Team organization Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 Lecture Schedule Spring 2017 (Monday) This schedule can be changed M A R

More information

MC Android Programming

MC Android Programming MC1921 - Android Programming Duration: 5 days Course Price: $3,395 Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse

More information

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 2 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. Android Widgets There are given a lot of android widgets with simplified

More information

Mobile Programming Lecture 7. Dialogs, Menus, and SharedPreferences

Mobile Programming Lecture 7. Dialogs, Menus, and SharedPreferences Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences Agenda Dialogs Menus SharedPreferences Android Application Components 1. Activity 2. Broadcast Receiver 3. Content Provider 4. Service

More information

Eventually, you'll be returned to the AVD Manager. From there, you'll see your new device.

Eventually, you'll be returned to the AVD Manager. From there, you'll see your new device. Let's get started! Start Studio We might have a bit of work to do here Create new project Let's give it a useful name Note the traditional convention for company/package names We don't need C++ support

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Intents. Your first app assignment

Intents. Your first app assignment Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work

More information

Android & iphone. Amir Eibagi. Localization

Android & iphone. Amir Eibagi. Localization Android & iphone Amir Eibagi Localization Topics Android Localization: Overview Language & Strings Country/region language variations Images & Media Currency, date & Time iphone Localization Language &

More information

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu Android UI Design Example GeoQuiz App Reference: Android Nerd Ranch, pgs 1 30 App presents

More information

Mobile Application Development

Mobile Application Development Mobile Application Development MTAT.03.262 Jakob Mass jakob.mass@ut.ee Goal Give you an idea of how to start developing mobile applications for Android Introduce the major concepts of Android applications,

More information

COSC 3P97 Mobile Computing

COSC 3P97 Mobile Computing COSC 3P97 Mobile Computing Mobile Computing 1.1 COSC 3P97 Prerequisites COSC 2P13, 3P32 Staff instructor: Me! teaching assistant: Steve Tkachuk Lectures (MCD205) Web COSC: http://www.cosc.brocku.ca/ COSC

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Application Components Hold the content of a message (E.g. convey a request for an activity to present an image) Lecture 2: Android Programming

More information

This lecture. The BrowserIntent Example (cont d)

This lecture. The BrowserIntent Example (cont d) This lecture 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 10: Working with the Web Browser Dr Dimitris C. Dracopoulos Android provides a full-featured web browser based on the Chromium open source

More information

ListView Containers. Resources. Creating a ListView

ListView Containers. Resources. Creating a ListView ListView Containers Resources https://developer.android.com/guide/topics/ui/layout/listview.html https://developer.android.com/reference/android/widget/listview.html Creating a ListView A ListView is a

More information

Overview of Activities

Overview of Activities d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems Programming

More information

Android Data Binding: This is the DSL you're looking for

Android Data Binding: This is the DSL you're looking for Android Data Binding: This is the DSL you're looking for Maksim Lin Freelance Android Developer www.manichord.com The plan Why Data Binding? Brief intro to Data Binding Library Adding Data Binding to an

More information

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial Revision history 90001431-13 Revision Date Description A October 2014 Original release. B October 2017 Rebranded the document. Edited the document.

More information

Lab 1: Getting Started With Android Programming

Lab 1: Getting Started With Android Programming Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Eng. Jehad Aldahdooh Mobile Computing Android Lab Lab 1: Getting Started With Android Programming To create a new Android Project

More information

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie User Interface Design" & Development -

More information

Android Programming (5 Days)

Android Programming (5 Days) www.peaklearningllc.com Android Programming (5 Days) Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse tools. This Android

More information

Mobile Computing Practice # 2c Android Applications - Interface

Mobile Computing Practice # 2c Android Applications - Interface Mobile Computing Practice # 2c Android Applications - Interface One more step in the restaurants application. 1. Design an alternative layout for showing up in landscape mode. Our current layout is not

More information

Let s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels.

Let s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels. Screens To begin with, here is some theory about screens. A screen has such physical properties as size and resolution. Screen size - a distance between two opposite corners of the screens, usually measured

More information

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI Specification: Approaches UIS: APPROACHES Programmatic approach: UI elements are created inside the application code Declarative approach: UI elements are listed

More information

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator. Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New

More information

14.1 Overview of Android

14.1 Overview of Android 14.1 Overview of Android - Blackberry smart phone appeared in 2003 First widely used mobile access to the Web - Smart phone market now dominated by Android, iphone, and Windows Phone - Tablets are now

More information

Creating a User Interface

Creating a User Interface Creating a User Interface Developing for Android devices is a complicated process that requires precision to work with. Android runs on numerous devices from smart-phones to tablets. Instead of using a

More information

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2. Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code

More information

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126 M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126 Submitted to: Sir Waqas Asghar MAY 23, 2017 SUBMITTED BY: REHAN ASGHAR Intent in Android What are Intent? An Intent is a messaging object you can use to request

More information

BCA 6. Question Bank

BCA 6. Question Bank BCA 6 030010601 : Introduction to Mobile Application Development Question Bank Unit 1: Introduction to Android and Development tools Short questions 1. What kind of tool is used to simulate Android application?

More information

<uses-permission android:name="android.permission.internet"/>

<uses-permission android:name=android.permission.internet/> Chapter 11 Playing Video 11.1 Introduction We have discussed how to play audio in Chapter 9 using the class MediaPlayer. This class can also play video clips. In fact, the Android multimedia framework

More information

Minds-on: Android. Session 2

Minds-on: Android. Session 2 Minds-on: Android Session 2 Paulo Baltarejo Sousa Instituto Superior de Engenharia do Porto 2016 Outline Activities UI Events Intents Practice Assignment 1 / 33 2 / 33 Activities Activity An activity provides

More information

A Crash Course to Android Mobile Platform

A Crash Course to Android Mobile Platform Enterprise Application Development using J2EE Shmulik London Lecture #2 A Crash Course to Android Mobile Platform Enterprise Application Development Using J2EE / Shmulik London 2004 Interdisciplinary Center

More information

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09 Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09 Hello, today we will create another application called a math quiz. This

More information

Android UI: Overview

Android UI: Overview 1 Android UI: Overview An Activity is the front end component and it can contain screens. Android screens are composed of components or screen containers and components within the containers Screen containers

More information

Android About.me/DavidCorrado Mobile Meetup Organizer

Android About.me/DavidCorrado Mobile Meetup Organizer Android Tips/Tricks @DavidCorrado About.me/DavidCorrado Mobile Meetup Organizer IDE Don t Use Eclipse Use either Android Studio/IntelliJ They are basically the same thing. They are both built off of IntelliJ

More information