Mobile Computing With Android ACST 4550 Intro to Android, Part 3

Slides:



Advertisements
Similar presentations
Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
Advertisements

CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
CE881: Mobile and Social Application Programming Simon M. Lucas Layouts.
Android User Interface
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
Android Application Development 2013 PClassic Chris Murphy 1.
Creating Android user interfaces using layouts 1Android user interfaces using layouts.
Android: versions Note that: Honeycomb (Android v3.0) A tablet-only release Jelly Bean (Android v4.1) Released on July 09, 2012.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Chapter 2: Simplify! The Android User Interface
Android Layouts. Layouts Define the user interface for an activity Layouts are defined in.xml files – within /res/layout folder – different layout can.
DUE Hello World on the Android Platform.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Using Android XML Resources.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
COMPUTER PROGRAMMING. Functions What is a function? A function is a group of statements that is executed when it is called from some point of the program.
Android Boot Camp for Developers Using Java, 3E
Application Development for mobile Devices
Computers and Scientific Thinking David Reed, Creighton University Functions and Libraries 1.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Silicon Valley Code Camp 2009 “Embellish Your Pictures” Build an Application for an Android Phone Jack Ha, Balwinder Kaur Oct 3, 2009 – 5:15PM Room CCL.
Demo 02 StartUpScreen Display. We would like to include a button in our demo app to "do something". In the activity_main.xml we define a "Calc" button.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Creating multiple views Introduction to intents Passing data to.
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
1 Mobile Computing Handling Different Display Sizes Copyright 2015 by Janson Industries.
© 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.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Android Drawing Units and The.
© 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.
Android Intents Nasrullah. Using the application context You use the application context to access settings and resources shared across multiple activity.
Classes, Interfaces and Packages
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, WEB:
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
CHAPTER 1 part 1 Introduction. Chapter objectives: Understand Android Learn the differences between Java and Android Java Examine the Android project.
Chapter 2: Simplify! The Android User Interface
Mobile Applications (Android Programming)
Android Mobile Application Development
Open Handset Alliance.
Mobile Application Development BSCS-7 Lecture # 2
Obtaining the Required Tools
Mobile Application Development Chapter 3 [Using Eclipse Android Studio for Android Development] IT448-Fall 2017 IT448- Fall2017.
Similar Polygons.
Mobile Application Development BSCS-7 Lecture # 8
MAD.
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Graphical Output Graphical Text.
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Scaling of Eclipse on High Density Displays
Android Layout Basics Topics
Operation System Program 4
Name: Rubaisha Rajpoot
HNDIT2417 Mobile Application Development
Java Inheritance.
Android Topics Threads and the MessageQueue
Mobile Computing With Android ACST 4550 Toast
CIS 470 Mobile App Development
Lecture 1 Runtime environments.
Mobile Programmming Dr. Mohsin Ali Memon.
Android Sensor Programming
Presentation transcript:

Mobile Computing With Android ACST 4550 Intro to Android, Part 3

The Context The Context in an Android App is a container of global information about an application environment that is provided by the Android OS. It allows access to application-specific resources and classes. The context must be passed to a View constructor, and it also must be passed to many other native Android class objects (like Toast). When you are in the Activity itself, you can use the “this” keyword to get the Context, but if you are in a thread created from the Activity you use the first method below, and to get it from a View thread you use the second: getApplicationContext(); // get’s context from an Activity thread getContext(); // get’s context from a View thread

Creating Multiple Activities You can run multiple Activities in an Android App. When you do this, the new Activity appears on top of the previous Activity, and the previous Activity will reappear when the new Activity is ended or when it restarts the previous Activity. To start (or launch) a new Activity, first you have to notify the Android OS by creating an “Intent” object, which is passed the Context of the current Activity, and the Class object of the new Activity. And then you can start the new Activity with a call to the startActivity() method: Intent myIntent = new Intent(getApplicationContext(), NewActivity.class); startActivity(myIntent);

Creating Multiple Activities Starting multiple Activities is different than switching from one View to another using setContentView(), because when you switch from one View to another, the old View is replaced in the current Activity and it is not simply placed behind the old View. If you have instantiated your own View object, you can maintain the View state from one setContentView() call to the next, but if you don’t do that, none of a previous View’s state is maintained for you.

The finish() method When an Activity is done and you want to close it from within your program, you should call the finish() method. This has the same effect as the user hitting the “back” or “return” button. Calling this method is somewhat similar to calling System.exit(0) in a Standard Java program. If there are multiple Activities running in an App, both finish() and System.exit(0) will only close the current one. In most cases, you should use the finish() method, but if you wanted to close an Activity from within a View, then you would use System.exit(0).

Drawing Units There are six basic units to use when identifying distance on the Android Screen: px, in, mm, pt, dp, and sp px - Pixels - corresponds to actual pixels on the screen. in - Inches - based on the physical size of the screen. mm - Millimeters - based on the physical size of the screen. pt - Points - 1/72 of an inch based on the physical size of the screen. dp - Density-independent Pixels - an abstract unit that is based on the physical density of the screen (see next slide) sp - Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference (see next slide).

Drawing Units dp - Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp". sp - Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.

Accessing Pre-Defined Strings In the “strings.xml” file of your Android project are string constants that you should use rather than including literal strings directly in views and code, so that you will be able to support multiple languages. Strings in the strings.xml file are formatted like so: <string name="str_name">This is a string</string> Then you can access the string in your code by loading it using the getString() method and the string’s ID path as follows: String theStr = getString(R.string.str_name);