Ideas about the modern Perl

October 15th, 2010

Perl is regarded as powerful but not elegant, just like the art work, it is easy to write but hard to read, maybe ;)
A lot of people are wondering what the modern Perl should be, here it is.
In fact, Perl could be as elegant as Python, see Dancer and Mojo for example, the key is not the language but the humor being

Reduce the android application’s memory footprint

October 14th, 2010

There are several ways to achieve this:

Make it work first, then make it better

September 12th, 2010

See details here, and don’t miss the other excellent articles on Oliveira’s blog.

Stick broadcast in Android

August 25th, 2010

What is the stick broadcast?
As the docs for Context.sendStickyBroadcast(...) says:

“sticky” meaning the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver()

And that is not the whole story,
the docs for Context.registerReceiver(...) says:

The system may broadcast Intents that are “sticky” — these stay around after the broadcast as finished, to be sent to any later registrations. If your IntentFilter matches one of these sticky Intents, that Intent will be returned by this function and sent to your receiver as if it had just been broadcast.

So you need not worry about missing the last “sticky” broadcast Intent before you register the receiver, just register it and handle the Intent in Reciever.onReciever(...)

Develop application for Android via V4L2

August 5th, 2010

I have finished developing several applications for Android via V4L2 API, such as FM Radio, Analog TV. It is very convenient for the user space library communicates with kernel space driver through V4L2. The main architecture from top to bottom is as below:

  1. application layer, interact with user and renders the GUI
  2. service layer, provides service for application via Binder mechanism
  3. hardware abstract layer, consists of two sub-layers, one is Java implementation which wraps the other one, Native implementation, through JNI, they two provide hardware function support
  4. library layer, provides APIs for upper layer, communicates with driver via V4L2
  5. the drivers

And here is a helpful site about V4L2

Get cheat sheet here

July 23rd, 2010

Get cheat sheet here, and to be a quick learner

How to install Busybox on your Android

July 22nd, 2010

Busybox is a toolbox of popular Linux commands such as cp, mv, and much more that can be installed on a “rooted” Android phone. To install it follow these steps:

  1. Download a proper Busybox binary from www.busybox.net, and put it onto the root folder of your SD card, then rename it to busybox
  2. Setup you Android SDK, run ADB shell, then type
    su
    mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
    cat /sdcard/busybox > /data/local/busybox
    chmod 755 /data/local/busybox
    /data/local/busybox mkdir /system/xbin
    cd /data/local
    ./busybox cp /data/local/busybox /system/xbin
    cd /system/xbin
    chmod 755 busybox
    ./busybox --install -s /system/xbin
    rm /data/local/busybox
    reboot

That should install it, enjoy

Avoid image auto-scaling by android

July 12th, 2010

The android framework is smart enough to render image resources into LCD with different size or density, but sometimes it is not good enough, for example: if we render image resources for a 160dpi LCD into a 240dpi one, the android should pre-scale the image by 1.5 times first, then at the layout stage, the image may be scaled again to fit the bounds.

So there are two problem here:

  1. much more work should be taken which will slow down the rendering process.
  2. the image quality will be decreased.

To avoid this you should:

  1. set android:targetSdk=”4″ in uses-sdk tag in AndroidManifest.xml, to disable compatible mode.
  2. put image resources in the proper directory, for example res/drawable-hdpi or res/drawable-nodpi.

Download android source code behind a proxy

June 30th, 2010

If you are behind a proxy and I guess you cannot download with git://android.git.kernel.org/tools/repo.git, don’t worry, you just need to update the following two files in your sync dir.

  1. .repo/manifest.xml, replace this line “git://android.git.kernel.org” with “http://android.git.kernel.org”
  2. .repo/repo/repo, replace this line with “git://android.git.kernel.org/tools/repo.git” with “android.git.kernel.org/tools/repo.git”

It means you just need to change “git” with “http” in the above two

Mirror Android repositories on a local server

June 20th, 2010

Here is an excellent guide, and Here is the gitosis instructions.