Objects First with Java

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 6 Overview Programming Tutorial 3: Sending/Receiving SMS Messages.
Advertisements

Programming with Android: Activities and Intents
1 Working with the Bluetooth radio Nilanjan Banerjee Mobile Systems Programming University of Arkansas Fayetteville, AR
Programming with Android: Activities and Intents Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Programming with Android: Activities and Intents Luca Bedogni Marco Di Felice Dipartimento di Informatica – Scienza e Ingegneria Università di Bologna.
Android 02: Activities David Meredith
Manifest File, Intents, and Multiple Activities. Manifest File.
The Activity Class 1.  One application component type  Provides a visual interface for a single screen  Typically supports one thing a user can do,
Cosc 5/4730 Android Content Providers and Intents.
Android Life Cycle CS328 Dick Steflik. Life Cycle The steps that an application goes through from starting to finishing Slightly different than normal.
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
@2011 Mihail L. Sichitiu1 Android Introduction Communication between Activities.
Mobile Programming Pertemuan 6 Presented by Mulyono Poltek NSC Surabaya.
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming.
SQLite Database. SQLite Public domain database – Advantages Small (about 150 KB) – Used on devices with limited resources Each database contained within.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Rajab Davudov. Agenda Eclipse, ADT and Android SDK APK file Fundamentals – Activity – Service – Content Provider – Broadcast Receiver – Intent Hello World.
CS378 - Mobile Computing Intents.
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.
Copyright© Jeffrey Jongko, Ateneo de Manila University Of Activities, Intents and Applications.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
COMP 365 Android Development.  Every android application has a manifest file called AndroidManifest.xml  Found in the Project folder  Contains critical.
How to start Visual Studio 2008 or 2010 (command-line program)
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
Linking Activities using Intents How to navigate between Android Activities 1Linking Activities using Intents.
Copyright© Jeffrey Jongko, Ateneo de Manila University Basic Views and Layouts.
Activity Android Club Agenda Hello Android application Application components Activity StartActivity.
Mobile Programming Midterm Review
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Creating multiple views Introduction to intents Passing data to.
Introducing Intents Intents Bind application components and navigate between them Transform device into collection of interconnected systems Creating a.
Intents 1 CS440. Intents  Message passing mechanism  Most common uses:  starting an Activity (open an , contact, etc.)  starting an Activity.
Android Intents Nasrullah. Using the application context You use the application context to access settings and resources shared across multiple activity.
Activity ANDROID CLUB Сегодня  Основные компоненты Android  Activity  Layout для Activity  Создание Activity  Launcher Activity  Activity.
Lecture 2: Android Concepts
Technische Universität München Services, IPC and RPC Gökhan Yilmaz, Benedikt Brück.
Activities and Intents Chapter 3 1. Objectives Explore an activity’s lifecycle Learn about saving and restoring an activity Understand intents and how.
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Putting together the AndroidManifest.xml file Creating multiple.
Developing Android Services. Objectives Creating a service that runs in background Performing long-running tasks in a separate thread Performing repeated.
CS371m - Mobile Computing Intents 1. Allow us to use applications and components that are already part of Android System – start activities – start services.
Introduction to android
Intents and Broadcast Receivers
Lecture 2: Android Concepts
several communicating screens
Programming with Android:
Android 5: Interacting with Other Apps
Linking Activities using Intents
Communication between Activities
CS499 – Mobile Application Development
Activities and Intents
Android Speech Recognition
Android Introduction Camera.
Developing Android Services
Android Programming Lecture 5
CIS 470 Mobile App Development
Many thanks to Jun Bum Lim for his help with this tutorial.
Java Lesson 36 Mr. Kalmes.
Mobile Computing With Android ACST 4550 Android Database Storage
Android Topics Asynchronous Callsbacks
Activities and Intents
CIS 470 Mobile App Development
Objects First with Java
Activities and Intents
Lecture 2: Android Concepts
Activities and Fragments
Chapter 5 Your Second Activity.
Activities, Fragments, and Intents
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Objects First with Java Class Business © David J. Barnes and Michael Kölling

Activity An Activity is the main object in an Android app. Lifecycle:

Better Ways to Organize the Code There are several times when the code is organized around an integer return value. onCreateDialog() onOptionsItemSelected() onActivityResult() This results in a string of “if…then…else” code that just stinks.

Better Ways to Organize the Code Use a table of classes. Do a table lookup of the code and Java reflection to call the right class.

GradeBox Example

Starting New Activities A common action for an activity is to start another activity. When another activity is started, the current activity is stopped and the new activity is created/started/resumed.

Starting New Activities: Intents Intents are communications about classes or executables or data Example: communicate which activity to start by creating an intent that indicates the class to use

Starting New Activities Two ways to start an activity To start an independent activity that will run, use startActivity() To start an activity that will return information to the current activity, use startActivityForResult() Both calls use intents to indicate which activity should start up

startActivity() Uri smsUri = Uri.parse("tel:"+grades.getStudent(itemPosition). getMobilePhoneNumber()); Intent sendIntent = new Intent(Intent.ACTION_VIEW, smsUri); sendIntent.putExtra("address", grades.getStudent(itemPosition).getMobilePhoneNumber()); sendIntent.putExtra("sms_body", "type message here"); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent);

startActivityForResult() Using this call, one gives the intent AND a returning value that identifies the activity. When the Activity is completed, the method onActivityResult() is called.

startActivityForResult() Intent gameIntent = new Intent(this, GameDisplay.class); startActivityForResult( gameIntent, R.id.class_display_games);

startActivityForResult() protected void onActivityResult( int requestCode, int resultCode, Intent intent) { super.onActivityResult( requestCode, resultCode, intent); if (resultCode != RESULT_OK) return; if (intent != null) { if (requestCode == R.id.class_display_games) { … }

GradeBox Example

Returning From an Activity To halt an Activity, call finish() To return to the Activity that created the current Activity, call setResult(): setResult(RESULT_OK, result); This means automatic return with the ID that it was created with.

GradeBox Example

Information in Intents You can insert information into an intent to communicate with the activity that is being started. The typical way is to Create a Bundle Put things into the Bundle Add the Bundle to the Intent through putExtras()

GradeBox Example

Retrieving Information Use the getIntent() call to retrieve the Intent Use the get…() call to get the extra you are looking for

GradeBox Example

Exercise: XML File

Interface Component Overview