Skip to content

Posts from the ‘Android’ Category

31
Aug

Working With Stateful ListView

What is Stateful ListView?

It’s not a coined term, but it’s obvious. Stateful ListView is a listview whose items change according to its state.the state is usually maintained by a custom ListAdapter.

Why would I need it?

I don’t know. But, I can tell you why did I need it. In my Birthdays application, I wanted to have a “Batch Edit” mode. When activated, it should allow users to mark multiple items using checkboxes. That means these checkboxes weren’t part of my “Standard” mode. I didn’t want to create whole new activity just to add a checkbox. So, I decided to have the checkbox in the hidden state by default. I wanted to somehow loop through all the items and make it visible.

Sounds pretty easy. What’s the problem?

The first one isn’t actually a problem. It is because of the way Android is designed. The ListView doesn’t load all the item at once to optimize memory management. Only visible items are loaded. So, one can’t exactly loop through all the items because they don’t exist. If you change only visible items, newly rendered items after scrolling don’t have the change. The new items are rendered by executing ListAdapter.getView() for each item. So, maintaining the state inside the adapter solves the issue.

Now all the new items are being rendered correctly but, it won’t change the already rendered (visible) items. To solve this, I combined the above two techniques – maintaining the state inside the ListAdapter for items not yet rendered and looping through all the visible items and changing them. This introduces another issue that consumed more time in identification and resolution then before.

Basically, if user switches between modes when the ListView is being scrolled, Android VM will throw NullPointerException because the requested ListItem doesn’t exist in the view.

What did you do?

The cause of this was the loop where I was trying to modify the items. When the function was being invoked, because of the still-scrolling ListView, indexes of visible ListItems changed and they were no longer available. I had to remove it for starters. Now, what I needed was a strategy to make the checkboxes visible for already rendered items. After a little bit of searching I found out that by calling Adapter.notifyDataSetChanged() I can re-render visible ListItem views. If anybody has an improved strategy to implement the scenario, please comment below. I will update the post accordingly.

The source code for Birthdays application I mentioned above can be accessed via Github.

19
Aug

Birthdays Released on Android Market

Yesterday, I released my first Android application on Android Market – Birthdays. It is a birthday reminder application which syncs all your contacts’ birthdays to your calendar.

One can say that I’m a forgetful person and while there are some advantages of this situation, I often forget birthdays of people who matter. As a solution to this, I started maintaining birthdate of a person into his/her contact. Back then, I had just bought an iPhone and I was pleased that it had a “Birthday” field in the address book. I didn’t hesitate paying $0.99 for a birthday reminder app which didn’t exactly “remind” me (iPhone didn’t support Push notifications or Calendar sync back then).To be exact, it helped only a little if at all.

In the same time period, I was also excited about Android as a development platform. When I got my first Android device, I tried out a few birthday reminder apps already available. Most of them didn’t work as I expected them to. While some did, they relied on a background service for notifications which will keep running at all times. So, I decided to start the development of yet another birthday reminder application which will get the job done while not being a resource-hog. While the journey of the development was quite educational, it was easier than I initially thought (probably because of a slight change in my job description). I still can’t believe it took me a year to develop and publish my first “real” application.

So, what’s next? The application is still very basic. I am going to explore android SDK some more by adding new features like facebook sync, two-way contact sync etc. I have had a lot of help from Android developer community so, I am going to write a few blog posts explaining some issues I faced in the development of this application as my contribution. I am also planning to open the source to public as soon as I am done with implementing all the features I have in my mind. The application source can be accessed from Github.

QR Code
If you haven’t yet tried it, give it a spin by downloading it from the Market. Do provide your feedback via comments below so that I can improve it further and make it more user-friendly.

A feature suggestion is also welcome. I will implement it as I get time to spare.

Note: Because of a major bug, all the calendar events created by Birthdays are being removed by Android upon reboot. I am working on an alternate way to sync the calendar. Please bear with me until I release a fix.

Changelog:

Birthdays v1.2 R6 (September 20, 2010):

  • Fixed the “Invalid Birthday” issue
  • Fixed crashes on Droid X
  • Corrected calendar event dates
  • Better calendar cleanup
  • A few minor bugfixes

Birthdays v1.1.beta (August 21, 2010):

  • Fixed the crash for non-HTC devices

Birthdays v1.0.beta (August 18, 2010):

  • Initial release
15
Jun

Rooting HTC Desire: The Hard Way

There are many HTC Desire Rooting tutorials and step-by-step guides out there. Best ones amongst them are probably this and this. There are easier methods like this, but I prefer simpler over easier (Yup, I’m too lazy to burn a CD. I’d rather do it without rebooting :P ). Before proceeding with the process I followed, I should mention that my HTC Desire is Singapore/Unlocked version which comes with RUU_Bravo_hTC_Asia_WWE_1.19.707.7_Radio_32.36.00.2 8U_4.06.00.02_2_release_126179_signed.exe ROM by default.

I primarily used Snow Leopard for this process (I had to use windows to make GoldCard). Following the above mentioned xda-developers guide pretty much did it. As it mentions, even I don’t have a branded (career locked) ROM, I needed a GoldCard to make it work (I came to know that after couple of failed attempts :P ). Anyway, following the guide for Mac OS X, everything else worked perfectly till the time came to restart device in recovery mode and flash update.zip from SD card. It failed to flash it because image verification failed. So, after spending some time on internet trying to find a solution, I finally found one. I found a way to enter a custom flasher menu in recovery mode by executing recovery-mac.sh (Which loads the green menu mentioned here). It took me a while to figure out that this menu doesn’t operate with volume up/down like the bootloader. So, here is the tip – The green recovery menu can be navigated using optical trackball; so it’s not stuck or frozen :P

So, finally I have my HTC Desire rooted. First thing I did was to get rid of the stock ROM. I took the Red Pill (Pays-ROM 2.0) and installed the ROM. Let’s see if I can find any difference in speed and battery usage.

Update: My desire keeps restarting if I click on new text message notification (More on that here). So, reverting back to the stock ROM for now. I hope I can work on my own ROM soon enough before I lose interest or I find a perfect ROM :)

8
Jun

HTC Desire vs iPhone 3G: My Verdict

It’s been around half a week since I have been using HTC Desire. I was very much happy with the initial impressions of the device. But, there is a big difference between playing around with the device and actually using it in my day-to-day schedule. So, I totally replaced my old iPhone 3G with HTC Desire for a couple of days after preparing it over the weekend.

Before going through preparation process (which include applications I’ve installed) comments on “Things I May Love” and some of “Things I love on iPhone” from previous post.

  • People (Contacts): Two words – absolutely amazing. Linking of contacts with exchange and facebook works seamlessly. Love it.
  • Google Calendar Sync: Very helpful. I don’t have to connect it to my computer to sync anymore. Can’t possibly forget any events and reminders :)
  • Integration to social networks: Great. Uploading photos to twitter/facebook/flickr is piece of cake. Even uploading a video to youtube is very easy.
  • Adobe Flash: Visited a few websites, which looked fine except veoh. I couldn’t watch any video there. Not sure what is the deal.
  • FM Radio: As I mentioned before, the reception is pretty weak. But, works flawlessly if the signal is strong. Anyway, I don’t think I will be using it much.
  • OTA Software Updates: Still waiting for Froyo to be available for Desire.
  • Lock text message to prevent deletion: I should have labeled it as “Things I love” in the first place.
  • Pattern-based Screen Lock: This one has turned out to be a disappointment. Even if I enable it, the default screen unlock (slide down) doesn’t go away. So, I have to unlock my screen twice. I hope HTC will fix this in next update. :(
  • Voice recognition: Did not use it that much but, mostly it is accurate.
  • DoubleTwist: As it turns out, it’s neither the most convenient nor the fastest music syncing I have seen. It takes too much time to refresh iTunes playlists (Maybe my library is too big but, I am looking for a worthy alternative to iTunes, right?). So far, copying the music directly to SD has been convenient.
  • Keyboard Accuracy: Now I am pretty sure that iPhone keyboard is far more accurate than the one on Android. I have tried HTC IME mod and swype. None of them made any difference. I still hope a little bit of practice will do it right.
  • Battery: Battery life is less than half of what my iPhone delivered. I don’t think it’s Google Talk because Android seems to be using most of it (more than 90% in some cases). I will try different suggestions from guys at xda developers forum to increase it.
  • Scratch-proof Screen: I assumed that all the high-end phones come with this feature now because iPhone has it from the beginning. But, sadly, I was wrong. I’ve got scratches on my screen and I hate it :( (who doesn’t?).

I went through Android Marketplace and downloaded all the alternatives to the applications I was using on my iPhone. I found android counterparts for some of them, alternative applications for some and some cool stuff that wasn’t available on iPhone. So here goes the list and comparison of all the applications I have on both phones.

Android Counterparts of the Apps I was using on iPhone:

  • Twitter: Official twitter client for iPhone was probably most opened application on my iPhone. Even though I am using peep as a widget, I installed official Android Twitter application. It is very different from its iPhone counterpart and lacks some features as well but, it simply works!
  • Foursquare: Another application I loved on iPhone. It is almost same as its iPhone counterpart on Android.
  • Dictionary.com: Sometimes, I get an urge to read literal meaning of some word. To quench that thirst, I kept it on my iPhone (Evidently, I am too lazy to open the browser). The best thing about it was, it worked without active internet connection. Sadly, it is not the case in its Android counterpart which requires internet connection. I am not sure whether it’s worth it.
  • Facebook: Almost same as its iPhone counterpart. I don’t use it much so, it doesn’t matter that much.
  • Evernote: Exactly same as its iPhone counterpart. Works for me :)
  • Boxee Remote: I use it once in a while when I am too lazy to get up to my keyboard. ;)

(Better or worse) Android alternatives to iPhone Applications:

  • EboBirthday (Alternative to Birthdays on iPhone): It is a birthday reminder application and it works well. It would have been better if it read birthdays from facebook, too. Considering it is free (compared to $2.99 for Birthdays) it does the job very well.
  • Astrid Tasks: (Half-alternative to Awesome Notes): It is a task list application with pretty good feature set. Awesome Notes is kinda awesome but, I can ignore the fact that it only does less than half things Awesome Notes does considering it is free. Edit: Astrid Tasks has improved a lot since I originally wrote this. It just may be better than Awesome Notes now.
  • Shazam (Alternative to Midomi Soundhound): Again, a free alternative to an excellent paid application. Sad thing is, it can’t identify live songs or hums. :(
  • Scoreboard (Alternative to ESPN Scorecenter): This one is not exactly convenient to use but, it’s an improvement over ESPN Scorecenter.
  • Settings Widget (Alternative to SBSettings): I used SBSettings to quickly turn on/off radios or kill processes. Android has got a built in Home Widget that does the same work. Nothing like it.

iPhone Applications I could not find on Android Market:

  • IMDB: I couldn’t even find any good alternatives. Being a movie buff, one of the must haves for me. Edit: Available in Android Market now.
  • eBay: Being an occasional eBayer, useful. Edit: Available in Android Market now.
  • Big Cinemas: Big Cinemas being the only multiplex in Mangalore, the city where I live, I used it every weekend to check out show times. I would love to have it on Desire.

(Awesome) Applications that are missing from iPhone:

  • Barcode Reader: Amazing piece of work. I love it when I don’t have to search Android Market for application that I just read a review about. Just flash the QR Code and I am good to go :)
  • Google Goggles: Still experimental and slow but, very cool application to have. (I don’t know if it is cool enough to use to impress girls :P )
  • ES File Explorer: Yes, a file explorer. Beat that iPhone.. :)
  • Google Talk/Lattitude: If you are into these services, these apps run in the background. You’re constantly annoyed/spied by friends :P
  • Google Earth/Sky Map: Not so useful but, cool pieces of work.

So, HTC Desire is overall as good as it gets over good old iPhone 3G. It is way more snappier, friendlier and cooler than iPhone 3G. Beside, now that Apple has discontinued it, I chose perfect time to upgrade. The only shortcomings are battery life, keyboard accuracy and lack of application availability. But still, they are not deal-breakers for me.

I haven’t tried my hand in custom ROM yet (heck, I didn’t even root it yet :oops: ). Once I get enough time, I will start developing on Android. Meanwhile, I am sure ROM chefs will work to remove all the pain points. 8)

P.S.: If anybody have a suggestion about alternatives to apps I want or any other cool applications, feel free to contact me.

Update: Now that I’ve got a couple of deep scratches on my Desire screen, I know that all the high end smartphones don’t come with scratch-resistant screens. Added it to the list.

5
Jun

Expectations and initial impressions of HTC Desire

I just got my first Android phone yesterday – HTC Desire. I have been using an iPhone 3G for a little more than a year and I like it a lot. But, coming from WinMo 6.1 platform, it was very different, and quite frankly, difficult to use. I always wanted to buy an Android device since the G1 came out. Obviously, I couldn’t do that till today.

Now that I have been a smartphone user from long back, I have some expectations set for my new phone. So, I was playing around with the phone and the OS from yesterday. As it is too early to declare whether it was worth upgrading to over an iPhone or not, I have identified features that might play a significant role in the process.

Things I love about HTC Desire over iPhone:

  • First and foremost, it doesn’t need to be jailbroken or unlocked in order to use it. I kinda hate apple for career locking the iPhone. Yes, there I said it. I have seen many enthusiastic users (yes, I am one of them) buying an iPhone only to find out that it contains the latest “baseband” and it cannot be jailbroken/unlocked. I mean, what’s the use spending a lot of money just to find out you got a music player instead of a smartphone. So much for making money, huh Apple?
  • Multitasking: Yes, I am aware that it is coming with iPhone OS 4. But, sadly multitasking will not be supported on iPhone 3G. Beside, I am not here to compare iPhone OS and Android, I am comparing two phones that I own and it is a fair comparison. I always wanted to run google talk in the background. I was using IM+ with Push in iPhone but, somehow push is not the same as running the app in background. Let’s see how does it work out.
  • Better Camera and Video Recording: You got to accept the fact that iPhone 3G camera sucks. I am delighted to get a far better one with video recording capabilities. Autofocus with face detection, Advanced Settings, Zooming, Geotagging and LED Flash are cherry on top. (I know, too many cherries :) )
  • Useful widgets on home screen: Being a former WinMo user, this is one of those things that went missing when I switched to iPhone. You can’t control what you have on your home screen (for iPhone, lock screen because there is no such thing as home screen). On top of that, it seems that HTC has improved home screens with Sense UI and I am glad that I will not have to open an application to check news/tweets/weather thanks to Sense widgets.
  • Notification Tray: Great original android concept. It’s a good thing that I won’t lose any notification like I do in iPhone and goodbye to those annoying Push messages.
  • Smart Dialing: Another thing that went missing when I “upgraded” to iPhone from WinMo. I am just too lazy to type whole number or name or when I don’t remember the name. :P
  • Bluetooth: Again, one more feature that went missing when I switched to iPhone. I never used bluetooth on iPhone because It couldn’t perform what I wanted (File/vCard transfers) and I wasn’t interested in what it could perform (Headset).
  • Notification LED: It was very convenient to monitor battery charging and notifications on my WinMo because of this. Another thing lost with iPhone. Anyway, not a “must need” feature but nice to have it.

Things I may love about HTC Desire compared to iPhone:

  • People (Contacts): iPhone contacts management and sync were nice and all but, what beats phone contacts integration with Google Contacts and Facbook? The linking and splitting of contacts looks nice and how can I forget contact groups? Despite all the excitement, my final verdict is reserved.
  • Google Calendar Sync: Automatic syncing with google calendar sounds useful. Never used it before but, I feel I will find it useful.
  • Integration to social networks: Ability to upload photos to Picasa/Flicker/Facebook as well as videos to Youtube directly from phone is sweet.
  • Adobe Flash: Well, it’s not 2015 yet and most of the websites still use flash to serve content like video and audio. I don’t particularly hate any of them. Flash has contributed so much to the web and I’m sure HTML5 will do the same (or more). Though probably HTML5 will replace flash eventually for audio/video, I simply don’t want to wait for it.
  • FM Radio: I never owned a phone with FM radio but, I guess once in a while it’s entertaining to listen to it rather than my library which doesn’t change frequently. But, I am still not happy with the fact that I have to use stereo headset in order to do it. (Update: I get static sound when the handsfree cable is near to my phone) (Update 2: Surprise surprise. I thought it will only work with HTC handsfree kit but it worked with my Head-Direct RE2.)
  • OTA Software Updates: Despite the fact that I have never done it, it sounds exciting. Will do that for Froyo update. Who wants to connect the phone to a computer to get latest software update? Then again, not so important for longer run because I will be playing around with different ROMs. ;)
  • Lock text message to prevent deletion: Small feature. But, I could use something like that to keep important text messages.
  • Pattern-based Screen Lock: iPhone has pin-based lock. But, somehow I feel this is cooler :)
  • Voice recognition: Google voice-to-text is good. I’d say it is 70% accurate for me. Can be helpful on bumpy roads sometimes. ;)

Things I loved on iPhone and are missing here/are not as good:

  • Bright Screen: I knew that AMOLED screens are not the best in terms of visibility in sunlight. But, after practically using it outside, I kinda miss the bright iPhone screen. Worse thing is, when set the brightness to “auto”, it doesn’t automatically adjust it to full when in sunlight. I have to do it manually. :(
  • Hardware Ringer/Vibrate switch: I absolutely love it. You can turn your phone silent without even looking at it. Perfect.
  • iTunes: I kinda like managing my audio library in iTunes, especially the ratings and play count. Wouldn’t want to lose that now, do we? (Update: Just tried Doubletwist – iTunes for Android which apparently lets me import iTunes playlists. Great, I’m happier now. :) )
  • Keyboard Accuracy: I don’t know if it’s not as accurate as iPhone but, I am having hard time typing on it. I hope it improves with practice.
  • Screenshots: iPhone has built-in functionality of taking screenshots without using an app (Wow, that’s the first). I kinda miss it in Android.
  • Turning the screen on: This sounds weird but, I have habit of turning the screen of my iPhone by pressing home button rather than power button. (Actually, double press it for music controls :) ) Anyway, as it seems, I can only bring unlock screen on desire by pressing power button and it’s annoying. I have found a way to overcome it but, it requires rooting. So, no biggie.
  • Scratch-resistant screen: I assumed that it’s a standard feature for a high-end touchphone. As it turns out, it isn’t. And I have learnt it the hard way. :(

So, these are my initial observations and final verdict is still pending. I will post more about “things I may love” and stuff like battery life later.

Update: Added scratch-resistant screen to the missing list.

12
Aug

Android Development For Beginners

Just started playing with Android SDK 1.5r3 a couple of days ago. I went through some architecture videos, Hello World and Notepad tutorials. In my opinion, the API is still not mature enough but, it holds much potential. I don’t own an Android handset and the emulator doesn’t provide all the applications but, I came to know from some blog posts that built-in Apps are pretty basic and they drastically need improvement.

I was planning to develop a series of basic applications (similar to what AppsAmuck is for iPhone) which could help other newbie Android developers like me to learn things faster. Then, I came across blog of bakhtiyor, who has already made a similar effort. I will go through these applications this weekend and probably add couple of new apps to the list.

Update: I already started a couple of applications but, couldn’t get time to complete them. I wish to resume the development as soon as I can.

12
Aug

Google introduces a “Simple” language for Android

I came across a blog post announcing Release of Simple, which is a language based on BASIC. Simple google code page (pun intended) has binary distributions available for download for Windows, Linux and Mac. Author has updated it with a couple of sample applications and a bunch of Reference pages in its Wiki. It is well-suited for “non-professional” programmers who want to develop applications on Android. If you ask me, it’s a remote possibility. But, it is a good gesture from Google to encourage adaptation of Android.