Code Painters The Art of Coding

18Dec/091

First Android platform build

After playing with Android SDK for a while, now it's time to try to build the platform. Unfortunately, Android documentation is not the best one I've ever seen, and some research is needed. Do they try to promote their web search engine this way? ;)

Fist step is to clone the repository, as described in this guide (I'm going to use donut branch). It goes smoothly, but takes a lot of time (my Internet link goes up to 120kB/s only). Continue reading…

Tagged as: 1 Comment
17Dec/092

Android 1.5 and ListView’s choiceMode

I've just discovered that setting the choiceMode attribute of the ListView element in the XML layout doesn't work on Android 1.5. Comparing ListView.java from 1.5 and 1.6 releases reveals the following difference (among others):

@@ -166,6 +174,8 @@
             setDividerHeight(dividerHeight);
         }

+        setChoiceMode(a.getInt(R.styleable.ListView_choiceMode, CHOICE_MODE_NONE));
+
         mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
         mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

The change is inside ListView's constructor. Looks like someone has forgotten to add the code to retrieve the choiceMode attribute, and that was fixed in 1.6. I've found no ticket for that in the Android tracker, however.

Anyway, if you want your code to be 1.5-compatible, you'd rather call setChoiceMode() explicitly in your code.

Tagged as: , 2 Comments
15Dec/090

Android platform guide

After playing with Android SDK for some time, now I'm trying to make my own platform build and hack around a bit. Recently I've found the Android Platform Developer's Guide site. It contains some very useful hints, but the site doesn't seem referenced from neither http://developer.android.com/ nor http://source.android.com/. Serious oversight, isn't it? Or did I overlook something?

Tagged as: No Comments
11Dec/0923

Android: IMEI number and the emulator

Update: Please see my latest post about this topic.

It is a common practice for mobile applications to identify the user by IMSI number (associated with the SIM card) or IMEI number (unique ID of the device). Of course, it is also possible on Android:

TelephonyManager manager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String imei = manager.getDeviceId();
String imsi = manager.getSubscriberId();

This code works perfectly fine on a real device, however under emulator IMEI is always all-zero and it's not configurable. It quickly becomes awkward when debugging a network-enabled application which uses IMEI as a user ID. Continue reading…

Tagged as: , 23 Comments