Solarex's Blog

我只想过,平平淡淡的生活,欲望啊,请放过脆弱的我

Android Message Handling Mechanism

| Comments

Android is a message driven, message driven several elements:

  • The message says: Message
  • Message queue: MessageQueue
  • The news cycle, remove the message processing for circulation: Looper
  • Message processing, message loop out messages from the message queue should be carried out after the processing of messages: Handler

Usually we use most often is Message and Handler, if you use HandlerThread or similar HandlerThread things may come into contact with Looper, while MessageQueue is used inside Looper, for the standard SDK, we are unable to instantiate and use (constructor is package visibility).    We usually come into contact with Looper, Message, Handler are realized by JAVA, Android for Linux based systems, the bottom with a C, C++, and NDK exist, how could the message driven model only exists in the JAVA layer, in fact, there are corresponding to the Java layer such as Looper, MessageQueue in the Native layer.

Android是消息驱动的,实现消息驱动有几个要素:

  • 消息的表示:Message
  • 消息队列:MessageQueue
  • 消息循环,用于循环取出消息进行处理:Looper
  • 消息处理,消息循环从消息队列中取出消息后要对消息进行处理:Handler

平时我们最常使用的就是Message与Handler了,如果使用过HandlerThread或者自己实现类似HandlerThread的东西可能还会接触到Looper,而MessageQueue是Looper内部使用的,对于标准的SDK,我们是无法实例化并使用的(构造函数是包可见性)。

我们平时接触到的Looper、Message、Handler都是用JAVA实现的,Android做为基于Linux的系统,底层用C、C++实现的,而且还有NDK的存在,消息驱动的模型怎么可能只存在于JAVA层,实际上,在Native层存在与Java层对应的类如Looper、MessageQueue等。

Setup Mac Development Environment

| Comments

System preferences

In Apple Icon > System Preferences:

  • Trackpad > Tap to click
  • Keyboard > Key Repeat > Fast (all the way to the right)
  • Keyboard > Delay Until Repeat > Short (all the way to the right)
  • Dock > Automatically hide and show the Dock

Python Tutorial

| Comments

Using GNU Command Line Tools on Mac OS X

| Comments

Unlike Ubuntu shipped with GNU command line tools,Mac OS X shipped with the BSD version,which make me WTF when I encountered with some compatibility issues.Fortunately,it’s quit easy to install gnu tools by using homebrew in Mac OS X and set them as default.