Posts

Showing posts with the label open source

How to write Android Service?

Image
How to write Android Service? Table of Contents Two kinds of Services in Android Local Service Remote Service Broadcast 1 Two kinds of Services in Android When we wanna make an Android app, we should put the time-consuming jobs into a service, actually, there are two kinds of services in Android, Local Service, and Remote Service. The difference between them is that whether they are running in the same process as the app, the local Services are running in the same process as the app, while the remote Services are running in the separate process, and I just need to add the following attribute to the AndroidManifest declaration to announce a remote service, it is a local Service without this attribute. android:process=":remote" After We build the Service, We need to communicate with this object, send a message to Service is obvious, I just need to bind to that Service. But how to receive announcement and messages from the Service, the mechanisms to do ...

Async Networking in Android

Async Networking in Android (Deprecated, I never use those technology anymore.)  Table of Contents Background Source code examples 1 Background A few days ago, people ask me a question, How to write an application which has to download the resources from the network? or Let me narrow the scope, how to write an android app, which can download the images from the Internet with HTTP protocol and insert the image into a view container like a ListView. So, in this scenario, because the networking connections are always resources burden works, the solution is always put the heavy jobs into the background threads. Following is the equation to that problem. Threads + Cache + HttpClient I found three ways to met this equation after study that topic. Use AsyncTask(thread) directly, put the networking job into a background AsyncTask. Use ThreadPool, which is better than AsyncTask, especially in massive networking connection scenario. Use Volley library, which is ...

Dropbox Hacking

Image
Dropbox hacking Table of Contents Background How Dropbox implement its command mode? Loading image from serialized data 1 Background Yesterday, I upgrade my ubuntu into Trusty Tahr, the development branch of the newest ubuntu. Dropbox is one of many problems after the upgrade, although I found the solution finally, I discovered that Dropbox's technology to release software is worth hacking. Another reason to hacking Dropbox is that I love it so much, my daily works in computers depended on it, it is the coolest cloud storage tool, absolutely the best one. The first time I run dropbox after I install it, it emits a dialog to indicate the progress of download a package from its website, which is the real program to does the sync job, and its default install location is ~/.dropbox-dist. I think that's so cool, and I wanna learn how to do it. This article is hacking Dropbox release package in a linux environment. I tried to hack its Mac OS X's package,...

Install GTK+-3.8.7 into Ubuntu 12.04 from scratch

Image
Install Gtk+-3.8.7 into Ubuntu 12.04 from scratch Table of Contents Preparation How the compile the source code from the beginning? 1 Preparation The first step is alway to download the needed package. I give the following shopping list: software package Download URL glib-2.36.4 http://ftp.gnome.org/pub/gnome/sources/glib/2.36/ gdk-pixbuf-2.28.2 http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.28/ atk-2.8.0 http://ftp.gnome.org/pub/gnome/sources/atk/2.8/ fontconfig-2.11.0 http://www.freedesktop.org/software/fontconfig/release/ harfbuzz-0.9.24 http://www.freedesktop.org/software/harfbuzz/release/ pango-1.34.1 http://ftp.gnome.org/pub/gnome/sources/pango/1.34/ libatk-bridge2.0 http://packages.ubuntu.com/zh-cn/quantal/libatk-bridge2.0-0 libatk-bridge2.0-dev http://packages.ubuntu.com/zh-cn/quantal/libatk-bridge2.0-dev gtk+-3.8.7 http://ftp.gnome.org/pub/gnome/sources/gtk+/3.8/ My operating system is Ubuntu 12.04 ...

Use readline library to built command line tools

Image
Use readline library to built command line tools Table of Contents 1 Why readline library? 2 How to use it? 1 Why readline library? As a Linux programmer, I always need to write some command line tools, with the help of GNU Readline library , this mission can be a snap. So what's the readline library gives for us, according to its official document? It provides a set of functions which allow users to edit command lines as they typed in. What's more, it also supports history recording and auto-completion. It is GNU software and is distributed under the terms of GPL license. 2 How to use it? I upload my source code, using the readline library, which implemented a silly command line tools with only two command inside – help and quit, but I can add another command easily in its framework. It support history recoding, which means you can browser the your command history by up/down keys, but it still cann't support command auto-completion(I will ad...

自制T恤,为开源软件作宣传

Image
五一期间没有事做,干什么呢?自制做个T恤,宣传linux吧!毛主席说过自己动手丰衣足食吗,更何况这也符合linux的精神。 选择目标:在linuxsir上得到启发,做个opensuse的logo,因为比较简单,而且自己用suse也有一年了,作个纪念吧。 行动:丙烯颜料(黄,青)两管,水粉笔(5号)一支,勾线用的小笔一支,白色圆领T恤一件,总共35元。 (其中T恤25元,其它各2.5元),还有用实验室的美工刀,和打印机打印了一张suse的logo。 最后效果还行,不过第一次做细节的掌握还不行,涂料弄得不均匀,但不仔细看观察不出来。 准备过几天热了,穿出去拉拉风!