User Dictionary Manager for Android (UDM)

by adrian vintu 3/3/2010 11:13:00 PM

Today I released another Android application.
User Dictionary Manager for Android is an application that allows you to export/import/delete/clean the user dictionary words found on your Android phone.
This special version also includes a built in list of approx 2000 most used words/expressions in the Romanian language.
I hope you will enjoy the application as much as I am and will take advantage of this useful tool.
The User Dictionary Manager for Android home page is http://udm.adrianvintu.com

EDIT: If you are an Android programmer, you must check this link out http://adrianvintu.com/blogengine/post/Colored-Logcat-Script-for-Windows.aspx

Screen shots

Before Romanian User Dictionary - Composing SMS
After Romanian User Dictionary - Composing SMS
See Dictionary of Phone - go to Locale and Text
From Locale and Text - go to User Dictionary.png

Force Locale on Android

by adrian vintu 1/14/2010 8:51:00 PM
While playing with localization on the Android for my app I came upon an annoying bug.
It seems running on Motorola Milestone the fonts were getting smaller on each locale update.

I use the following code for locale changing (from http://almondmendoza.com/2009/01/28/force-localize-an-application-on-android/):
String languageToLoad  = "de";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
Also in the AndroidManifest.xml I have (without this entry you get "Something wrong here, didn't expect "mypackagename" to be resumed"):
<activity
  android:label="@string/app_name"
  android:name=".Dex"
  android:configChanges="locale">
Here is how my screen should look like:



And here is how it was looking on Motorola Milestone.



After changing the Locale from Preferences the fonts keep gettting smaller and smaller



This was very annoying. I did not know exactly why this was happening.

So I decided to reproduce the Milestone in the emulator. I got the specifications of the Milestone from the web and created in Eclipse an AVD with a resolution of 480x854 and density of 240.



After that I was able to reproduce the bug. It seems the density was the issue here.
I searched for Android density and after some tries I found the solution. It seems I needed to have this in the AndroidManifest.xml
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
/>
The most important is the android:anyDensity =" true ". After this, the application was shown correctly even on the Motorola Milestone.

I hope this will be of help and don't forget to check out my enhanced logcat tool here http://adrianvintu.com/blogengine/post/Colored-Logcat-Script-for-Windows.aspx


EDIT: please read the comments of the article, you may find solutions to some of your localization problems - e.g. changing orientation resets locale, etc.

Comparison of Android vs IPhone

by adrian vintu 1/14/2010 7:22:00 PM
Today I made a comparison of Android vs IPhone. I made the list together with an IPhone enthusiast. The results were surprising for both of us. If fact, they were so surprising that the IPhone user is now inclined to go for the Android on the next phone purchase.
Here is the comparison of Android vs IPhone.

Pros for Android
  1. SMS delivery report - for the IPhone you need a third party apparently
  2. notifications without INTERNET - one of the biggest drawback of the IPhone is that you cannot have notifications without Internet -> the notifications are stored on the Apple servers
  3. can install applications from any site - IPhone applications can only be installed from the Apple store (unless the phone is jail broken)
  4. multiple physical menu buttons - used for navigation and quick shortcuts, allows greater screen size (no more software menus)
  5. physical menu button allows recent 6 tasks (like ALT+TAB in Windows) - absolutely useful
  6. the Home screen is organized in 3, 4 or 5 virtual screens, the rest of the applications lie in a list - usability, quick to access most used apps - on the IPhone there are "limitless" virtual screens on Home
  7. can install on the Home screen - widgets, shortcuts, folders
  8. physical keyboard - on some models
  9. open source OS
  10. can install different/homebrewed firmwares
  11. can install home brewed apps
  12. background apps/ multitasking
  13. can make own application to hook into anything - calling, traffic, media, encryption, etc
  14. dev SDK is free and cross platform. IPhone is for $100+ and only works on MAC.
  15. programming is done in Java, bridges exist from J2ME, C#, etc. IPhone uses Objective C
  16. programming - can run interpreters. IPhone only allows running Objective C byte code
  17. easy access to the SD card (both from computer and from the phone). can copy MP3s, read ebooks, etc
  18. cheaper than the IPhone
  19. easy removable/replaceable battery.
  20. 5 mega pixel camera + blitz/flash
Pros for IPhone
  1. screen brightness/clarity
  2. bigger sofware keyboard - because of the wider screen
  3. great 3D apps and harware
  4. easy data synchronization
  5. proximity sensor - saves battery and "locks" the screen
  6. zoom using two fingers - pictures, browser, etc - though some Android phones also support multi touch

DEX for Android - DEX pentru Android

by adrian vintu 12/15/2009 10:56:00 PM

Today I released an Android application.
DEX for Android is a Romanian explanatory dictionary for the Android platform that stores the dictionary on the phones SD card.
I am regular user of the http://dexonline.ro so I decided to make an offline Android client for it.
I hope you will enjoy the client as much as I am and will take advantage of this really useful tool.
The DEX for Android home page is http://dex.adrianvintu.com

Azi am publicat o aplicatie Android.
DEX pentru Android este un dictionar explicativ roman pentru platforma Android care stocheaza dictionarul pe cardul SD al telefonului.
Sunt un utilizator regulat al http://dexonline.ro si am decis  sa fac un client offline pt Android.
Sper ca va veti bucura de asta unealta si veti profita de ea cu success.
Pagina proiectului DEX pentru Android este http://dex.adrianvintu.com

EDIT: If you are an Android programmer, you must check this link out http://adrianvintu.com/blogengine/post/Colored-Logcat-Script-for-Windows.aspx

Screen shots

BlackBerry - IllegalStateException ArticInterface::DocPosToCaret

by adrian vintu 11/24/2009 2:26:00 PM
A few days ago I found another rare BlackBerry bug. I was playing with some list elements and everything was working fine until I ran the code on a BlackBerry Curve 8300.

I was suddenly presented with this popup.



I have never seen this error so I googled for it. Unfortunately there was no reasonable explanation. So I decided to investigate it.
First thing I did was to take a peek at the event log. I did it by pressing ALT+L+G+L+G and I got this.



Taking a look at the exception trace showed this.



I needed to see the full log for details, so I used
javaloader -u eventlog
to dump the event log (for this to work you need to check the  USB Cable Connected under the Simulate menu item of the emulator).
My javaloader file is located at c:\eclipse_g_341_jde7\plugins\ net.rim.eide.componentpack4.5.0_4.5.0.14\components\bin\JavaLoader.exe

The log looked like this.

guid:0x9C3CD62E3320B498 time: Mon Nov 23 15:05:00 2009  severity:1 type:3 app:Java Exception data:
        IllegalStateException
        ArticInterface::DocPosToCaret: error 3; formatted text length = 40;
        net_rim_cldc-11
         TextArea
         getTextBounds
         0x7B8E
        net_rim_cldc-9
         LabelField
         layout
         0x9D99
        net_rim_cldc-8
         Manager
         layoutChild
         0x1B98
        net_rim_cldc-11
         VerticalFieldManager
         sublayout
         0xC6F0
        net_rim_cldc-8
         Manager
         layout
         0x1A95
        net_rim_cldc-8
         Manager
         layoutChild
         0x1B98
        net_rim_cldc-11
         VerticalFieldManager
         sublayout
         0xC6F0
        net_rim_cldc-8
         Manager
         layout
         0x1A95
        net_rim_cldc-8
         Manager
         layoutChild
         0x1B98
        net_rim_cldc-11
         VerticalFieldManager
         sublayout
         0xC6F0
        net_rim_cldc-8
         Manager
         layout
         0x1A95
        net_rim_cldc-8
         Manager
         layoutChild
         0x1B98
        net_rim_cldc-11
         VerticalFieldManager
         sublayout
         0xC6F0
        net_rim_cldc-8
         Manager
         layout
         0x1A95
        net_rim_cldc-8
         Manager
         layoutChild
         0x1B98
        net_rim_cldc-8
         Screen
         layoutDelegate
         0x5375
        net_rim_cldc-2
         MIDPScreen
         sublayout
         0x9781
        net_rim_cldc-8
         Manager
         layout
         0x1A95
        net_rim_cldc-8
         Screen
         doLayout
         0x4B51
        net_rim_cldc-8
         UiEngineImpl
         pushScreen
         0xA538
        net_rim_cldc-8
         UiApplication
         pushScreen
         0x8A4B
        net_rim_cldc-2
         Display
         switchDisplayables
         0x3A60
        net_rim_cldc-2
         Display$SwitchDisplayablesRunnable
         run
         0x3FF5
        net_rim_cldc-5
         Application
         dispatchInvokeLater
         0xAAC
        net_rim_cldc-3
         MIDletMain
         dispatchInvokeLater
         0x4F78
        net_rim_cldc-5
         Application
         processNextMessage
         0x123D
        net_rim_cldc-5
         Application
         enterEventDispatcher
         0xA51
        net_rim_cldc-3
         MIDletMain
         main
         0x51FA
guid:0x97C9F5F641D25E5F time: Mon Nov 23 15:05:00 2009  severity:0 type:2 app:System data:JVM Error 104
guid:0x97C9F5F641D25E5F time: Mon Nov 23 15:05:00 2009  severity:0 type:2 app:System data:Uncaught: IllegalStateException

The event log shows a very interesting thing. It seems the J2ME list is rendered as a VerticalLayout that contains Labels.

We start by looking for TextArea. We cannot find it in the SDK so we look for the LabelField class. We find the LabelField in
C:\eclipse_g_341_jde7\plugins\net.rim.eide.componentpack4.5.0_4.5.0.14\components\lib\net_rim_api\net\rim\device\api\ui\component\LabelField.class
A quick look in the documentation of LabelField shows us the setText method can truly throw an IllegalStateException.

public void setText(Object text)

    Sets this field's label text.

    Parameters:
        text - Label text which may be a string, string buffer, character array, or byte array (may be null for an empty label).
    Throws:
        IllegalArgumentException - if text parameter is an unsupported type.

Source: BlackBerry JDE 4.5.0 API Reference: Class LabelField

Looking for the getTextBounds method gives us a few results, like
C:\eclipse_g_341_jde7\plugins\net.rim.eide.componentpack4.5.0_4.5.0.14\components\lib\net_rim_api\net\rim\device\internal\ui\Formatter.class
c:\eclipse_g_341_jde7\plugins\net.rim.eide.componentpack4.5.0_4.5.0.14\components\lib\net_rim_api\net\rim\device\api\ui\component\TextField.class
the method signature looks like
getTextBounds(IILnet/rim/device/api/ui/XYRect;Lnet/rim/device/internal/ui/ArticInterface$Line;II)

Since the TextArea is not available and the ArticInterface is also missing, we must move our search somewhere else.

What we can notice is the exception thrown has something to do with the caret - DocPosToCaret.

After a little bit of testing, I was able to reproduce the bug. It seems the bug appears when the list item contains a ‘\n’ char right in the beginning of the text and the text following will be long enough to need to be split on different lines.
Also, setting many ‘\n’ chars in the beginning will make the exception pop up for a smaller following text length.
Unfortunately, without the code we cannot say exactly how the algorithm in getTextBounds() works, but still, we now have a good picture of why this happens and how it can be avoided(for example, by removing the ‘\n’ chars from the beginning of the text, or by adding a space “ “ char in front of the text).

Some tech details:
1. this behavior only seems to exist in net.rim.eide.componentpack4.5.0_4.5.0.14 and not other emulators.
2. the bug appears on the BlackBerry Curve 8300 phone
3. you can download the code to reproduce the bug here ws_DocPosToCaretException.zip (599.40 kb)
4. the emulator specification looks like this


I hope you have enjoyed this rare to find bug, and if you want to see another one, a really funny one, then please also check this one here BlackBerry - This is sexy, isn’t it?.

Colored Logcat Script for Windows

by adrian vintu 11/2/2009 12:08:00 PM

I found a nice script from Jeff Sharkey that formats nicely and in color the adb logcat.
Unfortunately Jeffs script works only on *ix so I decided to make a port to Windows.

Here is a screenshot of the adb logcat without color

And here a screenshot of the the adb logcat with color

As you can see, the colored adb logcat is a huge improvement.

To easily use the code, copy the files color_console.py, coloredlogcat.py and logcat.bat to your Android SDK/Tools path like c:\android-sdk-windows-1.5_r3\tools\logcat.bat. Now, instead of running "adb logcat" just run "logcat".

Please be gentile with the code as I am not a Python programmer :)

You can download the files here colored_logcat.zip (3 kb)

Thanks go to
Jeff Sharkey
André Burgaud
ActiveState for ActivePython

BlackBerry - This is sexy, isn’t it?

by adrian vintu 10/15/2009 6:06:00 PM

Some time ago I found an interesting “feature” on the BlackBerry emulator.
It seems under special conditions we get some funny messages.

Luckily I was able to reproduce the behavior and here are the steps, the screens and the funny messages.

1. Run clean.bat in C:\eclipse_g_341_jde7\plugins\net.rim.eide.componentpack4.6.0_4.6.0.16\components\simulator\
or skip this but make sure the Contacts list is empty.

2. Copy my application to the simulator folder.

3. Run the application – should look like this.

4. Add any dummy contact, like this.

5. Run the application – you should get an error and get to this menu screen.

6. Choose “VM internal test” from the menu.

7. You should now get a series of screens looking like this. (1)

8. Screen 2.

9. Screen 3.

10. Screen 4.

11. Screen 5.

12. Screen 6.


So I got curious as to where the text comes from.

I looked for the “This is sexy, isn’t it?” string, but could not find it anywhere.
I almost gave up until I decided to try “bill” from the last screen, and to my surprise I got a result in Jvm.dll. Most of the strings were there. The file excerpt looks like this:

This *is* Banner    (1/1)   Patching Java   This *is* BANNER!   A Message   (too of fwee)   Oh no mr bill, something has gone horribly horribly wrong. oh nooo. o nooooooooo.

I was happy to find the source, but still no trace of “This is sexy, isn’t it?”.
Well, in my opinion this special text comes from some image memory copy operation, something like BitBlit in GDI.BitBlit.

Finally, mystery solved :)

Some tech details:
1. this behavior only seems to exist in net.rim.eide.componentpack4.6.0_4.6.0.16 and not other emulators.
2. other emulators offer the “VM internal test” menu option but do not show anything. They don’t even show a new screen.

As conclusion, I leave you with a question:

Who in the name of H and H is Bill and what is his role into all this?

If you find out, please let me know :)

Edit 2009-11-24: If you liked this article, you should also check another rare bug here BlackBerry - IllegalStateException ArticInterface::DocPosToCaret