service, and open the background thread to run related processing, specifically participate in thread learning notes, this example only examines service-related content. The return value tells the system what will happen if the service's process is killed: Start_sticky indicates that the service will return to the starting state, as Onstartcommand () is called,
Android Service (ii) automatic restart of Service
Continue with the analysis in the previous article, followed by the second question "Service Automatic Restart problem"
(1) Service Lifecycle
(2) Automatic restart of the Service
H
The application component (client) can bind a service by calling the bindservice () method. Then, the android system calls the onbind () callback method of the service, this method returns an ibinder object that interacts with the server.
This binding is asynchronous. The bindservice () method returns immediately and does not return an ibinder object to the clien
1. Service Introduction
A service is one of the four main components in the Android system (activity, service, broadcastreceiver, and contentprovider). It is similar to the activity level, but cannot run on its own and can only run on the background, and can interact with other components. The
raw service object.Mservice =NewMessenger (service); Mcallbacktext.settext ("Attached."); //we want to monitor the service for as long as We are//connected to it. Try{Message msg= Message.obtain (NULL, messengerservice.msg_register_client); Msg.replyto=Mmessenger; Mservice.send (msg); //Give It some value as
automatically calls this function. Initialization is generally performed in this function, for example, creating a thread.OnDestroy (): You do not need to implement it, depending on your needs. When a service is destroyed, the system automatically calls this function. In this function, purge the job, for example, terminate and recycle the thread.
(03) The client starts the service through startService.
(04
You can pass an intent object (specify the service to be started) to the startservice () method to start the service from an activity or other application component. The Android system calls the onstartcommand () method of the service and passes the intent object to it (you should not directly call the onstartcommand (
Service components are often used in android development. They are often used as backend services and must always run and be responsible for handling tasks that are not necessarily human. Some security software, such as 360, may end the process. If the Service is not maintained, it will be killed.
How to maintain the running status of the
Android Service is divided into two types:
Local Service: called in the same apk
Remote Service: called by another apk
Remote services must be completed using AIDL.What is AIDL?
AIDL (Android Interface Definition Language) is an IDL Language used to generate code for int
Android-async-http-based android service, android-async-http
1: Server Side/*** Created by LiuFei on 2016/1/22.*/Public class HttpService extends Service {@ OverridePublic IBinder onBind (Intent intent ){Return null;}@ OverridePublic int onStartCommand (Intent intent, int fl
Android Service Services Detailed
A Service Introduction
Service is one of the four major components of the Android system (activity, Service, Broadcastreceiver, ContentProvider), which is about the same leve
b.intent.received) {//Service is Already running, so we can immediately//publish the connection. If the service has been started and has been bound, directly back to the binder object, here conn is the aforementioned innerconnection agent, here see connected operation is actually by Do you notice a problem in the above, there is no unconnected method in Innerconnection, then how to us
1. Error descriptionToday in Android4.4 Xiaomi 4 mobile phone running my program without error, and on the Android 5.1 of the Huawei P7 run my program on the time of the following error, error prompts as follows:E/androidruntime (12500): FATAL Exception:maine/androidruntime (12500): Process:com. XTC. WatchPid:12500E/androidruntime (12500): Java. Lang. IllegalArgumentException: Service Intent must be explici
Android growth diary-learning of Service components of four Android ComponentsAfter reading the materials, the following is the related information of the Service: Definition: running in the background, invisible, no interface priority is higher than the purpose of the Activity: play music, record changes in the locati
The previously mentioned Service is a Local Service, that is, the Service and Client are in the same process (that is, within the same application), and the Service lifecycle is subject to the process lifecycle. In practical applications, sometimes you want to use the Service
Detailed explanation of Service (Background Service) in Android
This article mainly introduces the Service (Background Service) details in Android. This article describes the concept, role, lifecycle, startup method, and code inst
thread to do that work. (Service is not a separate process and not a separate thread)The service provides two main functions:Context.startservice () is used to start a service in the background;Context.bindservice () is used to bind other services in order to obtain services provided by another service;locally served
The most important component services and activities of Android are the communication problems between them. Of course, today we will not study the underlying implementation issues. I will study how to use the upper-layer applications.
First, the activity calls the service
This is relatively basic, and there are two common methods;
First, using intent, this is relatively simple. You can specify the package
About Web Service
Android applications usually run on mobile platforms. The hardware resources of mobile systems are far inferior to those of PC platforms. Whether it is storage or computing, it is possible to run some small applications on Android platforms, however, for a large amount of data processing, complex computing can only be deployed on remote servers,
Reading directory
I. What is a Service?
Ii. layout file writing
Iii. Code File writing
Iv. Compilation of project definition files
V. Running Effect
I. What is a Service?
Service is one of the components of the Android system, and Activity, Intent, Conent Provider and said that the four kings of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.