Tuesday, August 28, 2012

Really fast Android emulator

One of my most read aritle in this tiny blog is How to make Android emulator fast. The small trick about increase memory size indeed improve the speed, but not as much. Now we have a (almost) final solution to the problem, using the x86 based emulator!

The official documentation is here:
http://developer.android.com/tools/devices/emulator.html#acceleration

Right now only 2 emulator image are available. 2.3.3 and 4.0.3, without Google API support. But it's still a huge progress. Looking for the beautiful red line in console when start emulator.

[2012-08-27 21:03:20 - Emulator] HAX is working and emulator runs in fast virt mode

Sunday, May 6, 2012

avoid PendingIntent collision

Android always wants to challenge developers.

I was playing with Widget, RemoteViews and PendingIntent, everything worked nicely(at least seemed to be) until I tried to add two buttons in my widget.

The code always get the same pengingIntent! I tried to set actions, use different viable, no help. Then I figured out Android always try to merge similar PendingIntent, that's how FLAG_CANCEL_CURRENT and related flags can be implemented. now the question is: how can we prevent Android from doing this?

The answer is surprisingly simple yet hard to figure out if you trust Android documentation. Someone pointed out in stackoverflow, The solution is passing a different requestCode in getBroadcast public static PendingIntent getBroadcast (Context context, int requestCode, Intent intent, int flags)

But, hey, Android documentation says requestCode is not used!

requestCodePrivate request code for the sender (currently not used).

Wednesday, May 2, 2012

How to make Android emulator fast

Android emulator is much slower than iPhone simulator. Because it is emulating arm on top of x86, while iPhone simulator just runs native x86 code. But the default settings for Android emulator is so slow that is barely useable. Luckly we can change some settings to make it reasonable fast.

  1. Open "Android SDK and AVD Manager", create a new AVD or edit an existing one. 
  2. Click "New..." hardware to add a new hardware called "Device Ram Size"


  3. Change the value to 1024.

  4. Save the changes and launch the emulator.