most other smart phones display the unread email count as a small number in the lower right hand corner of the email application icon. I like that. After realizing that this is not supported by the GMail app, I started looking around the market for a widget that achieves this. All I found was a commercial widget, which did not satisfy me (the count did not get instantly updated when the unread mail count changed).
Therefore I want to develop a widget, which accomplishes exactly that.
Many of you probably have more experience in android development than I do, so I would be happy to hear your opinions.
I see two ways to realize this:
1) Somehow hook into a content provider of the GMail app and extract the unread mail count directly from there. Unfortunately the GMail app is not part of the SDK and closed source. Therefore I have no idea how to find out about the internal workings of the app and how to extract the unread mail count directly from there.
2) The second approach is much more indirect and has more overhead, but it will work nevertheless. I will let the user provide google username and password and log into the google imap server directly and find out how many unread mail there are. A port of the JavaMail library for the android OS should make this quite simple. The question remains when to update the mail count. What should trigger the update? A periodic time-out? Well, my first idea would be to update it when the widget is first started and then every time a new mail notification comes in. However I don't know whether this is possible. Can I tell my application to react to notifications, which where produced by another application (GMail app in our case) ?
I really think there should be a free unread gmail widget, which accomplishes this! I would be happy to receive feedback.