This is funny, because I have bumped into this issue literally yesterday myself...
Culprit is not if...else
itself, but name.isEmpty()
and alike.
LogCat should have given you a hint - for me it have logged comments saying "can not find virtual java.lang.String.isEmpty.....".
And if you hover over isEmpty()
in Eclipse, it will honestly tell you that isEmpty()
is introduced in... API level 9, which is 2.3.
If you want your code to run in Froyo, you need to use name.length() > 0
- this will work starting API level 1.
Of course, you can set minSDKLevel = 9 in manifest and forget about compatibility with 2.2 and below, if it is acceptable.