); } });
When you click the title component, the service receives the message and prints the intent parameter passed in. It also shows that the thread ID of the onHandlerIntent method execution is not the main thread. Why?
Let's take a look at the source code of the service:
public abstract class IntentService extends Service { private volatile Looper mServiceLooper; private volatile ServiceHandler mServiceHandler; private S
1.Android the process of DVM and the process of Linux, whether the application process is the same concept:A: DVM is a dalivk virtual machine. Each Android application runs in its own process and has a DALIVK virtual machine instance. And each DVM is a process in Linux. So it can be considered the same concept.What kinds of animations are there in 2.android? What are their characteristics and differences?A: Two kinds, one is tween animation, one is frame animation. Tween animations, which enable
/w3cnote/android-tutorial-handler-message.html) Third, the implementation flowchart of Handler(Image source: http://www.runoob.com/w3cnote/android-tutorial-handler-message.html) Flowchart Analysis: related nouns
UI Thread : is our main thread, the system initializes a Looper object when creating the UI thread, and also creates a MessageQueue associated with it;
Handler: The function is to send and process information, if you want Hand
execution and specified interval loop execution.Thread pools include: Newcachedthreadpool () cache thread pool, newfixedthreadpool () fixed thread pool, Newscheduledthreadpool () scheduled thread pool, Singlethreadexecutor single-Instance thread62.Android Message Queuing model.Android uses Looper, handler to implement the message loop mechanism, the Android message loop is for threads (each thread can have its own message queue and message loop).In A
In the Android messaging mechanism. It not only provides a message loop for Java used by application development. In fact, the Java mechanism finally depends on native to achieve. The native not only provides a set of messaging and processing mechanisms, but also provides a listening mechanism that defines the I/O time of the file description descriptor. Let's analyze it from the detailed code below.Key classes for the native layer:Looper.cpp. The hibernate and wake mechanisms for pollonce and w
This article we will introduce to you in the future Handlerthread this class, we used to use a thread to perform a time-consuming task always new thread to run, when the task is finished, the thread will be automatically destroyed, if again by the new task, we have to create new thread .... We assume such a scenario, we use the ListView to load the graph list, when we swipe down, it is necessary to constantly request network resources, that is, the need to constantly thread to load network resou
Android.os.bundle;import android.os.handler;import Android.os.handlerthread;import Android.os.looper;import Android.os.message;public class HandlerTest2 extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) {//TODO auto-generated method Stubsuper.oncreate (savedinstancestate); Setcontentview (r.layout.main);//Print the IDSystem.out.println of the current thread ("activity-->" + Thread.CurrentThread (). GetId ());//generates a Handlerthread object that implements the fun
In the Android messaging mechanism, it not only provides a message loop for Java that application development uses. In fact, the Java mechanism ultimately depends on native to achieve. The native not only provides a set of messaging and processing mechanisms, but also provides a listener mechanism for the I/O time of the custom file descriptor. Let's analyze it from the specific code below.Key classes for the native layer:Looper.cpp. The hibernate and wake mechanisms for pollonce and wake are pr
process:Flowchart Analysis:Related nounsUI Thread : Is our main thread, the system initializes a Looper object when creating the UI thread, and also creates a MessageQueue associated with it; Handler: The function is to send and process information, if you want handler to work properly, there is a Looper object in the current threadMessage : Handler received and processed message objectMessageQueue : Mess
Recently found some information about the communication between Android threads, organized and learned a bit, and made a simple example.Andriod provides Handler and Looper to meet the communication between threads. For example, a sub-thread downloads a picture from the network and sends a message to the main thread when it is downloaded, and this message is passed by binding to the handler of the main thread.on Android, where threads are divided into
There are many and thorough descriptions of this topic on the Internet, such:
Http://www.cnblogs.com/xirihanlin/archive/2011/04/11/2012746.html
Http://disanji.net/2011/01/23/android-looper-handler-thread/
Http://zhoujianghai.iteye.com/blog/1097156
In the process of using handler, the following should be the most:
Mhandler. sendmessage (MSG,...); (1)
Mhandler. Post (mrunnable); (2)
I believe that the first sentence can be used every day. Here message
1. Question 1) Why multithreading is required? 2) How to Implement multithreading? 3) What is the core of the multithreading mechanism? 4) How many implementation methods are there? 2. Problem Analysis 1) The essence of Multithreading is
Asynchronous Processing
In an intuitive sense, users should not feel "very stuck ". Eg: If you click the button to download a song and the button is pressed, the user experience will be poor. 2) multi-threaded implementation implements runnable or extends thread
The concept of 1,handlerWhat is Handler used for?1) Perform scheduled tasks, perform certain tasks at scheduled times, and can simulate timers2) Inter-thread communication. When the Android app starts, a main thread is created, and the main thread creates aMessage Queuing to process various messages. When you create a child thread, you can get the parent thread in your child threadCreates a handler object that can be used to send messages to the parent thread's message queue. Because AndroidRequ
1 PackageCom.example.gp08_day26_handler3;2 3 ImportAndroid.os.Bundle;4 ImportAndroid.os.Handler;5 ImportAndroid.os.Looper;6 ImportAndroid.os.Message;7 Importandroid.app.Activity;8 ImportAndroid.view.Menu;9 ImportAndroid.view.View;Ten One /** A * The main thread sends messages to child threads - * @authorQQ - * the */ - Public classMainactivityextendsActivity { - - PrivateHandler Handler;//you need to instantiate in a child thread + @Override - protected voidonCreate (Bundle savedi
Handler1. MessageMesssge is a message passed between threads, which can carry a small amount of information inside, to exchange data between different threading, the What field of the message, and in addition to using the Arg1 and Arg2 fields to carry some integral data, using the Obj field to carry a single Object object.2.HandlerHandler the processor, it is used primarily to send and process messages. Sending a message typically uses the handler SendMessage method, and the sending message pass
held and cannot be recycled by GC, which can result in a memory leak. The workaround is simple, handler to static, eliminate the internal anonymous reference, and change the object's reference to weakreferenceStatic classImagedonehandlerextendsHandler {weakreferenceImageView; WeakReferencebitmap; WeakReferenceURL; Zimage.cachetype CacheType; Imagedonehandler (Looper Looper, ImageView _ima
The following questions are found in the online summary, thank you for sharing! Hope, our common progress, find their favorite company,:1.android DVM Process and Linux this process. Whether the application is on the same concept:Answer: DVM is a dalivk virtual machine. Each Android application executes in its own process and has a DALIVK virtual machine instance. And each DVM is a process in Linux. So I can feel the same concept.What kinds of animations are there in 2.android? What are their cha
Each context has a looper handle the messages sent by each handler, and the function that Looper processes the message is:Msg.target.dispatchMessage (msg);Here msg is handler sent to Looper message, MSG bound handler, so there will not be a message wrong handler situation, in the handler Dispatchmessge Source:/*** Handle system messages here. */ Public voidDi
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.