Software Practice 3 Today s lecture Today s Task Porting Android App. in real device

Similar documents
Mobile Programming Practice Explicit intent Implicit intent Intent filter Lab#4 PA #1

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

Intents. 18 December 2018 Lecture Dec 2018 SE 435: Development in the Android Environment 1

Multiple Activities. Many apps have multiple activities

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

Intents and Intent Filters

The Intent Class Starting Activities with Intents. Explicit Activation Implicit Activation via Intent resolution

Overview. Lecture: Implicit Calling via Share Implicit Receiving via Share Launch Telephone Launch Settings Homework

CMSC436: Fall 2013 Week 3 Lab

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

Mobile Application Development Android

Android framework overview Activity lifecycle and states

By The Name of Allah. The Islamic University of Gaza Faculty of Engineering Computer Department Final Exam. Mobile Computing

THE CATHOLIC UNIVERSITY OF EASTERN AFRICA A. M. E. C. E. A

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

LECTURE 12 BROADCAST RECEIVERS

Mobile Programming Practice Background processing AsynTask Service Broadcast receiver Lab #5

Android Programming Lecture 7 9/23/2011

INTRODUCTION TO ANDROID

Embedded Systems Programming - PA8001

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Programming with Android: Activities and Intents. Dipartimento di Informatica Scienza e Ingegneria Università di Bologna

Introduction to Android Multimedia

Outline. Admin. Example: TipCalc. Android: Event Handler Blocking, Android Inter-Thread, Process Communications. Recap: Android UI App Basic Concepts

Real-Time Embedded Systems

Programming with Android: Intents. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Application Fundamentals

Android. Operating System and Architecture. Android. Screens. Main features

CS434/534: Topics in Networked (Networking) Systems

A Crash Course to Android Mobile Platform

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

Intents. Repo:

Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

The Intent Class Starting Activities with Intents. Explicit Activation Implicit Activation via Intent resolution

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Using Intents to Launch Activities

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

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

Minds-on: Android. Session 2

INTENTS android.content.intent

BCS3283-Mobile Application Development

Mobile Programming Lecture 9. Bound Services, Location, Sensors, IntentFilter

Android Intents. Notes are based on: Android Developers

LECTURE NOTES OF APPLICATION ACTIVITIES

Software Practice 3 Today s lecture Today s Task

Manifest.xml. Activity.java

EMBEDDED SYSTEMS PROGRAMMING Application Basics

Introduction to Android Development

Basic UI elements: Defining Activity UI in the code. Marco Ronchetti Università degli Studi di Trento

Tabel mysql. Kode di PHP. Config.php. Service.php

Overview of Activities

Activities. Repo:

Developing Android Applications

CS 193A. Multiple Activities and Intents

Intents & Intent Filters. codeandroid.org

MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR

Software Practice 3 Today s lecture Today s Task

Why using intents. Activity. Screen1 Screen 2

Android Services. Victor Matos Cleveland State University. Services

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism

Activities and Fragments

Android Activities. Akhilesh Tyagi

Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]

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

App Development for Android. Prabhaker Matet

else if(rb2.ischecked()) {

CSCU9YH Development with Android

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

Android/Java Lightning Tutorial JULY 30, 2018

CMSC436: Fall 2013 Week 4 Lab

Services. service: A background task used by an app.

Localizing Exception Faults in Android Applications

Lab 5 Periodic Task Scheduling

Online Learning Application

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

Basic GUI elements - exercises

Starting Another Activity Preferences

Mobile Platforms and Middleware

EMBEDDED SYSTEMS PROGRAMMING Android Services

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

Applications. Marco Ronchetti Università degli Studi di Trento

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

Android Beginners Workshop

Embedded Systems Programming - PA8001

Broadcast receivers. Marco Ronchetti Università degli Studi di Trento

Have a development environment in 256 or 255 Be familiar with the application lifecycle

Practical Problem: Create an Android app that having following layouts.

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

Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26

Intents, Intent Filters, and Invoking Activities: Part I: Using Class Name

Accelerating Information Technology Innovation

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Simple Currency Converter

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

CS 234/334 Lab 1: Android Jump Start

UNDERSTANDING ACTIVITIES

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Mobile Application Development MyRent Settings

Solving an Android Threading Problem

Transcription:

1 Software Practice 3 Today s lecture Today s Task Porting Android App. in real device Prof. Hwansoo Han T.A. Jeonghwan Park 43

INTENT 2

3 Android Intent An abstract description of a message Request actions from other components start Activity start Service (after midterm) submit broadcast message Implicit / explicit Intent

4 Implicit Intent Create unspecified activity using pre-defined requests ACTION_VIEW webpage or map, etc ACTION_CALL phone call ACTION_SEND send email Activity B Activity A Intent 1 Intent-filter Intent 2 Intent 2 Activity C

5 Multiple Candidates for Intent Activity A Intent 1 Intent-filter Intent 1 Activity B Intent-filter Intent 1 Activity C

6 Example of Creating Implicit Intent EditText Button

Example of Creating Implicit Intent Constructor public Intent(String action) public Intent(String action, Uri uri) Action strings for instantiating Intent is statically defined in Intent class protected void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.main); } Button button = findviewbyid(r.id.submit); button.setonclicklistener(new View.OnClickListener() { @Override public void onclick(view view) { EditText edittext = MyActivity.this.findViewById(R.id.editText); Uri url = Uri.parse(editText.getText().toString()); Intent intent = new Intent(Intent.ACTION_VIEW, url); if (intent.resolveactivity(getpackagemanager())!= null) { startactivity(intent); } } }); 7

Example of Creating Implicit Intent Useful methods in Intent class as implicit public ComponentName resolveactivity(packagemanager pm); This method returns the name of component which can handle the given Intent protected void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.main); } Button button = findviewbyid(r.id.submit); button.setonclicklistener(new View.OnClickListener() { @Override public void onclick(view view) { EditText edittext = MyActivity.this.findViewById(R.id.editText); Uri url = Uri.parse(editText.getText().toString()); Intent intent = new Intent(Intent.ACTION_VIEW, url); if (intent.resolveactivity(getpackagemanager())!= null) { startactivity(intent); } } }); 8

9 Receiving Implicit Intent Receive with BroadcastReceiver Receive Intent which is broadcasted from application Usually used when application does not need to react the message Receive with Activity Receive Intent which is passed with startacitivty() method Used when Intent must be reacted via Activity

10 Explicit Intent Start An Activity specified in Intent object Pass parameter for personalizing Components Activity A Intent-filter Intent 1 (for B) Activity B Intent-filter Activity C

11 Why Need Explicit Intent id: pw: John ***** Login Hi,?

12 Why Need Explicit Intent id: pw: John ***** Hi, John! Login Explicit Intent

Example of Creating Explicit Intent Same class, but different constructor public Intent(Context packagecontext, class<?> cls); packagecontext is the Context of current Activity cls is the class of taget Activity Set parameter to Intent putextra(string name, ); // means various type protected void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.main); } Button button = findviewbyid(r.id.submit); button.setonclicklistener(new View.OnClickListener() { @Override public void onclick(view view) { EditText edittext = MyActivity.this.findViewById(R.id.editText); Intent intent = new Intent(MyActivity.this, otheractivity.class); intent.putextra("mydata", edittext.gettext().tostring()); startactivity(intent); } }); 13

14 Receiver Activity of Implicit/Explicit Intent public Intent getintent(); Get Intent object which is submitted from previous Component Useful method in Intent class public String getstringextra(string name); returns the String data which declared as name if the type of return value is integer, use getintextra(name) protected void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.other); Intent intent = getintent(); String text = intent.getstringextra("mydata"); TextView textview = findviewbyid(r.id.textview); textview.settext(text);

15 Go Back to Previous Acitivity Android supports go-back mechanism as Back Stack Back Stack stores the history of previous Activitys startactivity(intent) method automatically set the current Activity to be paused and push current Activity into Back Stack

BROADCAST 16

17 Broadcast Sending message protocol which declared by Android system or other application Implicit Intent is exactly same with the broadcast message

18 Intent-filter Define the actions which Component will receive in AndroidManifest define a Component to receive ACTION_MAIN <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> define a Component to receive ACTION_VIEW <intent-filter> <action android:name="android.intent.action.view" /> </intent-filter> define a Component to receive user-defined action <intent-filter> <action android:name="this.is.my.own.action.hello_world" /> </intent-filter>

19 Broadcast Intent void sendbroadcast(intent intent); submit intent as broadcast message to Android system protected void oncreate(@nullable Bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Uri uri = Uri.parse("http://www.naver.com"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); } sendbroadcast(intent);

BroadcastReceiver BroadcastReceiver class is already implemented for you public class Receiver extends BroadcastReceiver { @Override public void onreceive(context context, Intent intent) { String action = intent.getaction(); } } if (action.equals("android.intent.action.view")) { Toast.makeText(context, intent.getdata().tostring(), Toast.LENGTH_LONG).show(); } *Toast: Android popup message 20

21 Manifest for BroadcastReceiver Define intent-filter <receiver android:name=".receiver"> <intent-filter> <action android:name="android.intent.action.view" /> <action android:name="android.intent.action.send" /> </intent-filter> </receiver>

22 [Lab Practice #4] Implement two applications satisfying the following conditions first application having two Activitys main Activity for generating explicit Intent to another Activity another Activity for generating implicit Intent other for receiving an Activity that cannot created from launcher, but only by Intent

23 [Lab Practice #4] main Activity of first application contain two EditText for getting name and keyword contain one Button for generating explicit Intent to another Activity another Activity of first application contain two TextView; name and keryword which is passed from explicit Intent contain a button for generating implicit Intent with ACTION_VIEW

24 [Lab Practice #4] Example of first application

25 [Lab Practice #4] main Acitivty of other application contain one TextView which prints the Uri from implicit Intent

26 [Lab Practice #4] Example of other application