Speech Service & client(Activity) 2013.10.16 오지영.

Slides:



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

Services. Application component No user interface Two main uses Performing background processing Supporting remote method execution.
Programming with Android: Notifications, Threads, Services
Application Fundamentals Android Development. Announcements Posting in D2L Tutorials.
Cosc 5/4730 Android Services. What is a service? From android developer web pages: Most confusion about the Service class actually revolves around what.
CSE2102 Introduction to Software Engineering Lab 2 Sept/4/2013.
The Android Activity Lifecycle. Slide 2 Introduction Working with the Android logging system Rotation and multiple layouts Understanding the Android activity.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
More on User Interface Android Applications. Layouts Linear Layout Relative Layout Table Layout Grid View Tab Layout List View.
System broadcasts and services. System broadcast events. EventDescription Intent.ACTION_BOOT_COMPLETEDBoot completed. Requires the android.permission.RECE.
Mobile Programming Pertemuan 6 Presented by Mulyono Poltek NSC Surabaya.
박 종 혁 컴퓨터 보안 및 운영체제 연구실 MobiSys '11 Proceedings of the 9th international conference on Mobile systems, applications,
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Content Providers & Services.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton.
Rajab Davudov. Agenda Eclipse, ADT and Android SDK APK file Fundamentals – Activity – Service – Content Provider – Broadcast Receiver – Intent Hello World.
Using Intents to Broadcast Events Intents Can be used to broadcast messages anonymously Between components via the sendBroadcast method As a result Broadcast.
Cosc 5/4730 Broadcast Receiver. Broadcast receiver A broadcast receiver (short receiver) – is an Android component which allows you to register for system.
Android ICC Part II Inter-component communication.
COMP 365 Android Development.  Perform operations in the background  Services do not have a user interface (UI)  Can run without appearing on screen.
Mobile Application Development using Android Lecture 2.
CS378 - Mobile Computing Intents.
로봇 모니터링 2/2 UNIT 21 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Broadcasting Service 2.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
Activities and Intents. Activities Activity is a window that contains the user interface of your application,typically an application has one or more.
Copyright© Jeffrey Jongko, Ateneo de Manila University Of Activities, Intents and Applications.
10/10/2015 E.R.Edwards 10/10/2015 Staffordshire University School of Computing Introduction to Android Overview of Android System Android Components Component.
Overview of Android Application Development
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
Android - Broadcast Receivers
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
ANDROID L. Grewe Components  Java Standard Development Kit (JDK) (download) (latest version)  AndroidStudio.
Services A Service is an application component that can perform long-running operations in the background and does not provide a user interface. An application.
Activity Android Club Agenda Hello Android application Application components Activity StartActivity.
Mobile Programming Midterm Review
DKU-MUST Mobile ICT Education Center 10. Activity and Intent.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Creating multiple views Introduction to intents Passing data to.
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android.
Lecture 2: Android Concepts
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
Services. What is a Service? A Service is not a separate process. A Service is not a thread. A Service itself is actually very simple, providing two main.
Developing Android Services. Objectives Creating a service that runs in background Performing long-running tasks in a separate thread Performing repeated.
Android Application -Architecture.
Intents and Broadcast Receivers
Lecture 2: Android Concepts
Broadcast receivers.
CS371m - Mobile Computing Services and Broadcast Receivers
Basic Activities and Intents
Lecture 7: Service Topics: Services, Playing Media.
Instructor: Mazhar Hussain
What's Happening Today Working with Images
Activities and Intents
Android Mobile Application Development
The Android Activity Lifecycle
Android Application Development android.cs.uchicago.edu
Android Programming Lecture 9
Developing Android Services
null, true, and false are also reserved.
Android Topics Android Activity Lifecycle and Experiment Toast
Activities and Intents
Android Developer Fundamentals V2 Lesson 5
Service Services.
Lecture 7: Service Topics: Services, Broadcast Receiver, Playing Media.
SE4S701 Mobile Application Development
Lecture 2: Android Concepts
Android Development Tools
CIS 470 Mobile App Development
Mobile Programming Broadcast Receivers.
Presentation transcript:

Speech Service & client(Activity) 오지영

Android Application Application Package Activity BroadCast Receiver Content Provider Service

Android Service  Service  안드로이드 Application 을 구성하는 컴포넌트 중 하나  Activity 처럼 사용자와 상호작용 하는 컴포넌트가 아니라 Background 에서 동작하 는 컴포넌트  Activity 화면에서 동작뿐만 아니라 Activity 가 종료되어 있는 상태에서 동작하기 위 해 만들어진 컴포넌트  예 :MP3 플레이어  Service 시작과 중지 함수  startService(Intent Service)  stopService(Intent Service)  두 함수는 Context class 소속 (Context class 다음 장에서 소개 )

Context class  Overview  Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.

Context class – startService, stopService Method  public abstract ComponentName startService(Intent service)  Request that a given application service be started  parameters  service : Identifies the service to be started. The Intent may specify either an explicit component name to start, or a logical description (action, category, etc) to match an IntentFilter published by a service. Additional values may be included in the Intent extras to supply arguments along with this specific start callIntentFilter  Returns  If the service is being started or is already running, the ComponentName of the actual service that was started is returned; else if the service does not exist null is returned.ComponentName  public abstract boolean stopService(Intent service)  Request that a given application service be stopped. If the service is not running, nothing happens. Otherwise it is stopped. Note that calls to startService() are not counted -- this stops the service no matter how many times it was started.  Parameters  service : Description of the service to be stopped. The Intent may specify either an explicit component name to start, or a logical description (action, category, etc) to match an IntentFilter published by a service.IntentFilter  Returns  If there is a service matching the given Intent that is already running, then it is stopped and true is returned; else false is returned.

Service 처리과정  Service 주기  Activity 에서 startService() 를 호출하면  Service 의 onCreate() -> onStartCommand() 순서대로 처리

Service 예제 : Music Player Service-Project, Activity 구현한 서비스 mp3 를 play, stop 함

Service 예제 : Music Player Service- AndroidManifest.xml 프로젝트의 AndroidManifest 에 service 를 등록

Service 예제 : Music Player Service-MainActivity.java Activit 에서 service 를 호출

Service 예제 : Music Player Service-MyService.java

Broadcast Receiver  BroadcastReceiver  Component 들 간에 메시지를 전달

Context class – sendBroadcast Method  public abstract void sendBroadcast(Intent intent)  Broadcast the given intent to all interested BroadcastReceivers. This call is asynchronous; it returns immediately, and you will continue executing while the receivers are run. No results are propagated from receivers and receivers can not abort the broadcast  Parmaters  intent : The Intent to broadcast; all receivers matching this Intent will receive the broadcast.

Toast class  Overview  A toast is a view containing a quick little message for the user. The toast class helps you create and show those. When the view is shown to the user, appears as a floating view over the application. It will never receive focus. The user will probably be in the middle of typing something else. The idea is to be as unobtrusive as possible, while still showing the user the information you want them to see. Two examples are the volume control, and the brief message saying that your settings have been saved  public Method  public static Toast makeText(Coontext, CharSequence text, int duration)  Make a standard toast that just contains a text view.  Parameters  context : The context to use. Usually your Application or Activity object.  text : The text to show. Can be formatted text.  duration : How long to display the message. Either LENGTH_SHORT or LENGTH_LONG.

Broadcast Receiver ( 방송하는 패키지 )

Broadcast Receiver- 정적 Receiver  Receiver 를 고정해서 등록하고 원하는 방송에 반응하는 Receiver

Broadcast Receiver- 정적 Receiver 결과

Broadcast Receiver- 동적 Receiver  AndroidManifest.xml 에 등록하지 않음

IntentFilter 를 생성하여 방송과 매칭될 Action 과 데이터를 등록 BroadcastReceiver 객체를 생성, onReceiver() 함수 구현 방송이 들어오면 onReceiver() 함수가 호출 BroadcastReciver 객체를 등록

Broadcast Receiver- 동적 Receiver 결과

Broadcast Receiver- 동적 Receiver  동적 리시버의 특징  자신을 등록한 Component 의 생명 주기가 끝나명 사라짐  unregisterReceiver() 함수 : 등록 해제  Component 내에 Receiver 소스가 존재하므로 Activity 내에 모든 맴버 객체에 접근 가능  정적 Receiver 의 경우 특정 Component 에 포함되어 있지 않으므로 멤버변수에 접근 불가능

처리 과정 RecognitionService(background) servicename : voice.wins.or.kr.service app Main Acitivity BroadcastReceiver name : restReceiver.wins.or.kr.service 1. startService(intent) 2. Recognition 3. intent.putExtra(value) 4. sendBroadcast(intent) 5. intent.getExtras() 6. send data to mainActivity ⓐ ⓑ ⓒ

ServiceClient-project, AndroidManifest.xml 프로젝트의 AndroidManifest 에 Receiver 등록

ServiceClient-MainActivity.java onResume() / onPause() Activity 위에 다른 Activity 가 올라왔거나 focus 를 읽었거나 다시 얻을 때 불림 onStart() / onStop() Activity 가 완전히 화면을 벗어날때 예 : 홈키를 눌러 홈화면으로 이동

ServiceClient-MainActivity.java Service 호출

ServiceClient-TestReceiver.java

testService-project, AndroidManifest.xml

RecognitionService-VoiceRecognitionService.java