ITEC535 – Mobile Programming

Slides:



Advertisements
Similar presentations
Android architecture overview
Advertisements

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.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Who Am I And Why Am I Here I’m professor Stephen Fickas in CIS – you can call me Steve. I have a research group that works with mobile devices (since 1995!)
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
Layout and Control in UI The user interface (UI) is the graphical interface user can see and interact with your app comprising UI controls like textbox,
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Presenting Lists of Data. Lists of Data Issues involved – unknown number of elements – allowing the user to scroll Data sources – most common ArrayList.
Android Application Development Tutorial. Topics Lecture 5 Overview Overview of Networking Programming Tutorial 2: Downloading from the Internet.
1 Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources, Listener 10/9/2012 Y. Richard Yang.
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.
Chapter 2: Simplify! The Android User Interface
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
ANDROID – INTERFACE AND LAYOUT L. Grewe. Interfaces: Two Alternatives Code or XML  You have two ways you can create the interface(s) of your Application.
Mobile Programming Lecture 6
DUE Hello World on the Android Platform.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
1 Introducing Activity and Intent. 2 Memory LinearLayout, weight=2 LinearLayout, weight=1 TextView ListView.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
Video Games list lab 6  At the end of this lab you will be expected to know:  What Views, View Groups, Layouts, and Widgets are and how they relate to.
ANDROID – A FIRST PROGRAM L. Grewe Using AndroidStudio –basic Android  Lets do a “Hello World Project”  Start up AndroidStudio (assume you have installed.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Chapter 2: Simplify! The Android User Interface
Lab7 – Appendix.
Introduction to android
Android Programming - Features
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Android Application Development 1 6 May 2018
Android N Amanquah.
several communicating screens
Adapting to Display Orientation
GUI Programming Fundamentals
Android – Event Handling
Mobile Application Development Chapter 3 [Using Eclipse Android Studio for Android Development] IT448-Fall 2017 IT448- Fall2017.
Android Introduction Hello World.
Android External Resources
Android Widgets 1 7 August 2018
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Android Introduction Hello Views Part 1.
תכנות ב android אליהו חלסצ'י.
Mobile Software Development Framework: Android
Android Introduction Hello Views Part 2.
CIS 470 Mobile App Development
Android Programming Lecture 6
CIS 470 Mobile App Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Android Developer Fundamentals V2
CIS 470 Mobile App Development
CIS 470 Mobile App Development
ITEC535 – Mobile Programming
Activities, Fragments, and Intents
Android Sensor Programming
Android Sensor Programming
Android Sensor Programming
Presentation transcript:

ITEC535 – Mobile Programming BTEP205 İşletim Sistemleri Eastern Mediterranean University School of Computing and Technology Master of Information Technology ITEC535 – Mobile Programming Application Lifecycle and Activities Dr.Ahmet Rizaner

Traditional Java Application ITEC535 - Mobile Programming

Simple Android Application Design: ITEC535 - Mobile Programming

Simple Android Application: Example: An application with two screens. Each screen is composed of several GUI elements. ITEC535 - Mobile Programming

Simple Android Application: Our Initial Goal: Our goal: An Application with one Activity with one View (a big textbox) ITEC535 - Mobile Programming

Application Priority ITEC535 - Mobile Programming

Activity States ITEC535 - Mobile Programming

Applications and Activities Applications and Activities are just Java classes: android.app.Application android.app.Activity We will interact with them using member functions. Initially, we will use a default Application setup and focus on building Activities. ITEC535 - Mobile Programming

Android Application Lifecycle ITEC535 - Mobile Programming

Android Applications Most of the applications created in Android will fall into one of the following categories: Foreground: An application that’s useful only when it’s in the foreground. Background: An application with limited interaction that spends most of its lifetime hidden. Intermittent: Expects some interactivity but does most of its work in the background. Widget: Some applications are represented only as a home-screen widget. ITEC535 - Mobile Programming

Limited permanent storage capacity Small screens with low resolution Compared to desktop or notebook computers, mobile devices have relatively: Low processing power Limited RAM Limited permanent storage capacity Small screens with low resolution High costs associated with data transfer Unreliable data connections Limited battery life ITEC535 - Mobile Programming

Activity is the base class for the visual, interactive components of your application; it is roughly equivalent to a Form in traditional desktop development. The skeleton code for an Activity-based class is shown below; note that it extends Activity, overriding the onCreatemethod. package com.paad.helloworld; import android.app.Activity; import android.os.Bundle; public class HelloWorld extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } ITEC535 - Mobile Programming

What’s missing from this template is the layout of the visual interface. In Android, visual components are called Views, which are similar to controls in traditional desktop development. The Hello World template created by the wizard overrides the onCreatemethod to call setContentView, which lays out the user interface by inflating a layout resource, as highlighted below: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } ITEC535 - Mobile Programming

The resources for an Android project are stored in the res folder of your project hierarchy, which includes drawable, layout and values subfolders. The ADT plug-in interprets these resources to provide design-time access to them through the R variable. ITEC535 - Mobile Programming

The UI layout defined in the main The UI layout defined in the main.xml file created by the Android project template: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_height="wrap_content" android:text="Hello World, HelloWorld" /> </LinearLayout> ITEC535 - Mobile Programming

Defining your UI in XML and inflating is the preferred way of implementing your user interfaces, as it decouples your application logic from your UI design. To get access to your UI elements in code, you add identifier attributes to them in the XML definition. You can then use the findViewByIdmethod to return a reference to each named item. ITEC535 - Mobile Programming

And the following snippet shows how to get access to it in code: The following XML snippet shows an ID attribute added to the Text View widget in the Hello World template: <TextView android:id="@+id/myTextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello World, HelloWorld" /> And the following snippet shows how to get access to it in code: TextView myTextView = (TextView)findViewById(R.id.myTextView); ITEC535 - Mobile Programming

To Do List Example Create another project using the wizard, then modify the main layout to include a ListView and an EditText within a LinearLayout. It’s important to give both the EditText and ListView an ID so you can get references to them both in code. <LinearLayout xmlns:android="http://schemas.android.com/ap k/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <EditText android:id="@+id/myEditText" android:layout_height="wrap_content" android:text="New To Do Item" /> <ListView android:id="@+id/myListView" </LinearLayout> ITEC535 - Mobile Programming

To Do List Example With your user interface defined, open the ToDoListActivity from your project’s source folder. In this example you’ll make all your changes by overriding the onCreatemethod. Start by inflating your UI using setContentView and then get references to the ListView and EditText using findViewById. ITEC535 - Mobile Programming

To Do List Example public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Inflate your view setContentView(R.layout.main); // Get references to UI widgets ListView myListView = (ListView)findViewById(R.id.myListView); final EditText myEditText = (EditText)findViewById(R.id.myEditText); } ITEC535 - Mobile Programming

To Do List Example Still within onCreate, define an ArrayList of Strings to store each to-do list item. You can bind a ListView to an ArrayList using an ArrayAdapter, so create a new ArrayAdapter instance to bind the to-do item array to the ListView. ITEC535 - Mobile Programming

To Do List Example public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView myListView = (ListView)findViewById(R.id.myListView); final EditText myEditText = (EditText)findViewById(R.id.myEditText); // Create the array list of to do items final ArrayList<String> todoItems = new ArrayList<String>(); // Create the array adapter to bind the array to the listview final ArrayAdapter<String> aa; aa = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,todoItems); // Bind the array adapter to the listview. myListView.setAdapter(aa); } ITEC535 - Mobile Programming

To Do List Example The final step to make this to-do list functional is to let users add new to-do items. Add an onKeyListener to the EditText that listens for an ‘‘ENTER’’ before adding the contents of the EditText to the to-do list array and notifying the ArrayAdapter of the change. Then clear the EditText to prepare for another item. ITEC535 - Mobile Programming

To Do List Example ... myEditText.setOnKeyListener(new EditText.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) if (keyCode == KeyEvent.KEYCODE_ENTER){ todoItems.add(0, myEditText.getText().toString()); aa.notifyDataSetChanged(); myEditText.setText(""); return true; } return false; }); ITEC535 - Mobile Programming