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
Ideas about the modern Perl
October 15th, 2010Reduce the android application’s memory footprint
October 14th, 2010There are several ways to achieve this:
- An article: developing apps within android’s 16mb memory limit
- A software: ProGuard
- A topic: what’s the best way for OEM to organize it’s own resources? If you have to support a lot of customized resource for different products, and intend to put them all into the res/ directory
Make it work first, then make it better
September 12th, 2010See details here, and don’t miss the other excellent articles on Oliveira’s blog.
Stick broadcast in Android
August 25th, 2010What 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, 2010I 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:
- application layer, interact with user and renders the GUI
- service layer, provides service for application via Binder mechanism
- 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
- library layer, provides APIs for upper layer, communicates with driver via V4L2
- the drivers
And here is a helpful site about V4L2
Get cheat sheet here
July 23rd, 2010Get cheat sheet here, and to be a quick learner
How to install Busybox on your Android
July 22nd, 2010Busybox 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:
- 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
-
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, 2010The 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:
- much more work should be taken which will slow down the rendering process.
- the image quality will be decreased.
To avoid this you should:
- set android:targetSdk=”4″ in uses-sdk tag in AndroidManifest.xml, to disable compatible mode.
- 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, 2010If 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.
- .repo/manifest.xml, replace this line “git://android.git.kernel.org” with “http://android.git.kernel.org”
- .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