Update code to support down to android 2.2 because isEmpty only available above API9