Service ANDROID CLUB 2015. Сегодня  Service Service - служба  Работает в фоновом режиме  Не имеет пользовательского интерфейса.

Slides:



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

1 Android Introduction Hello Threads. 2 Goal Create an application that uses a background thread as a UDP server to receive messages from the UDP client.
Services. Application component No user interface Two main uses Performing background processing Supporting remote method execution.
void count_down (int count) { for(i=count; i>1; i--) printf(" %d\t", count); } printf("A%d\n", count); if(count>1) count_down(count-1); printf("B%d\n",
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
Monitoring battery use. New app, BatteryMonitor Add permission: BATTERY_STATS The battery is monitored by receiving broadcasts of battery state information.
Instructore: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Concurrent and.
Thread synchronization Example:Producer/Consumer Relationship Buffer –Shared memory region Producer thread –Calls produce method to add item to buffer.
Recording and playing audio. App Make app AudioFun with 4 buttons – Start recording (id=StartRecording) – Stop recording (id=StopRecording) – Start playback.
Unit 141 Threads What is a Thread? Multithreading Creating Threads – Subclassing java.lang.Thread Example 1 Creating Threads – Implementing java.lang.Runnable.
The Activity Class 1.  One application component type  Provides a visual interface for a single screen  Typically supports one thing a user can do,
16-Jun-15 Producer-Consumer An example of using Threads.
1 Working with the Android Services Nilanjan Banerjee Mobile Systems Programming University of Arkansas Fayetteville, AR
Concurrency Java Threads. Fundamentals Concurrency defines parallel activity Synchronization is necessary in order for parallel activities to share results.
© Amir Kirsh Threads Written by Amir Kirsh. 2 Lesson’s Objectives By the end of this lesson you will: Be familiar with the Java threads syntax and API.
@2011 Mihail L. Sichitiu1 Android Introduction Hello Views Part 1.
Cosc 5/4730 A little on threads and Messages: Handler class.
Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton.
Broadcast intents.
Chapter 15 Multithreading F Threads Concept  Creating Threads by Extending the Thread class  Creating Threads by Implementing the Runnable Interface.
Android Services Mobile Application Development Selected Topics – CPIT Oct-15.
COMP 365 Android Development.  Perform operations in the background  Services do not have a user interface (UI)  Can run without appearing on screen.
DUE Hello World on the Android Platform.
로봇 모니터링 2/2 UNIT 21 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Broadcasting Service 2.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Threads and Services. Background Processes One of the key differences between Android and iPhone is the ability to run things in the background on Android.
Lecture 16: Multithreaded Programming. public partial class Form1 : Form { Thread ct; Thread rt; public static int circle_sleep = 0; public static int.
Semaphores, Locks and Monitors By Samah Ibrahim And Dena Missak.
Android 13: Services and Content Providers Kirk Scott 1.
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.
Practice Session 8 Blocking queues Producers-Consumers pattern Semaphore Futures and Callables Advanced Thread Synchronization Methods CountDownLatch Thread.
Threading Eriq Muhammad Adams J
Mobile Programming Midterm Review
Advanced Programming 2004, based on LY Stefanus’s slides slide 8.1 Multithreading : Thread Scheduling ThreadGroup.
HTTP ANDROID CLUB 2015.
1 Software Construction and Evolution - CSSE 375 Exception Handling – Chaining & Threading Steve Chenoweth Office: Moench Room F220 Phone: (812)
Android Threads. Threads Android will show an “ANR” error if a View does not return from handling an event within 5 seconds Or, if some code running in.
Android Service -播放音樂 建國科技大學 資管系 饒瑞佶 2013/7 V1. Android Service Service 是跟 Activity 並行 – 一個音樂播放程式若 沒使用 Service ,即使按 home 鍵畫面離 開之後,音樂還是照播 – 如果再執行一次程式,新撥放的音樂會跟先前撥放的一起撥,
Mobile Development. Name: Saurabh Software Developer.
Java Producer-Consumer Monitor From: Concurrent Programming: The Java Programming Language By Steven J. Hartley Oxford University Press, 1998.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization Codes.
 2002 Prentice Hall, Inc. All rights reserved. Outline HoldIntegerUnsyn chronized.java Line 4 Lines 7-13 Lines // Fig. 15.6: HoldIntegerUnsynchronized.java.
Semaphores CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Threads and Multithreading. Multiprocessing Modern operating systems are multiprocessing Appear to do more than one thing at a time Three general approaches:
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Activity ANDROID CLUB Сегодня  Основные компоненты Android  Activity  Layout для Activity  Создание Activity  Launcher Activity  Activity.
Java Applets Adding Animation. Import Files You still need to include the same files: –import java.applet.*; –import java.awt.*;
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Technische Universität München Services, IPC and RPC Gökhan Yilmaz, Benedikt Brück.
Уведомление пользователя ANDROID CLUB Сегодня  Toast  Диалог  Уведомление.
Speech Service & client(Activity) 오지영.
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.
Making content providers
CS499 – Mobile Application Development
Cleveland State University
Java Concurrency.
THREADS.
Threads Chate Patanothai.
Developing Android Services
null, true, and false are also reserved.
Condition Variables and Producer/Consumer
CIS 470 Mobile App Development
Condition Variables and Producer/Consumer
Service Services.
CIS 470 Mobile App Development
Internal Services CSE 5236: Mobile Application Development
Presentation transcript:

Service ANDROID CLUB 2015

Сегодня  Service

Service - служба  Работает в фоновом режиме  Не имеет пользовательского интерфейса

Зачем нам Service?  Может долго работать  Предназначен для задач, требующих много времени

Демо

Пример public void onCreate() { super.onCreate(); Toast.makeText(getApplicationContext(), "Создаеться служба", Toast. LENGTH_LONG ).show(); public int onStartCommand(Intent intent, int flags, int startId) { Toast.makeText(getApplicationContext(), "Служба работает", Toast. LENGTH_LONG ).show(); return super.onStartCommand(intent, flags, startId); public void onDestroy() { super.onDestroy(); Toast.makeText(getApplicationContext(), "Служба остановилась", Toast. LENGTH_LONG ).show(); }

Пример 2: секундомер public int onStartCommand(Intent intent, int flags, int startId) { new Thread() public void run() { while ( true ) { try { Thread.sleep(1000); } catch (InterruptedException e) { } count ++; Log.d( "Countdown", String.valueOf( count )); } } }.start(); return super.onStartCommand(intent, flags, startId); }

Пример 3: плеер  public class MusicService extends Service { private MediaPlayer player public void onCreate() { super.onCreate(); player = MediaPlayer.create( this, R.raw. ride ); public int onStartCommand(Intent intent, int flags, int startId) { player.start(); return START_STICKY ; public void onDestroy() { player.stop(); player.release(); public IBinder onBind(Intent intent) { return null ; } }

ContentProvider  База данных общедоступных информаций  Браузер – Вкладки, История  История звонков  Контакты  Медиа – музыка, фотографии  База данных часто используемых слов

Формат  CONTENT://AUTHORITY/PATH/ID  AUTHORITY – ID content provider  TYPE – тип данных  ID  content://com.android.contacts/contacts

Демо