3

So basically I'm attempting to make an interactive live wallaper that basically displays your unread gmail emails on your wallpaper. I'm trying to figure out how to access a person's gmail account on their device (with their permission of course).

I came across this old question: How to get the number of unread gmail mails (on android) - which detailed how to get the number of unread emails and was hoping that would be a start. But my app was being denied the permission: com.google.android.gm.permission.READ_GMAIL. Upon further research I found this support thread: http://www.google.bg/support/forum/p/gmail/thread?tid=1728955d050a12bd&hl=en - which basically says that at version 2.3.5 of Gmail they shut off that non-public api access to Gmail. Which broke a lot of apps at the time.. But yeah.

So basically. I was wondering if there's a new correct way to do this? I haven't been able to find one. Any help would be greatly appreciated. Thanks,

Community
  • 1
  • 1
Brayden
  • 521
  • 1
  • 5
  • 17
  • Did you try or think about using a Java MAPI library (e.g. JMapi) ? You'd have to re-request the user's email login information, but you could then independently read the gmail inbox. – Matt H Nov 29 '11 at 20:52
  • So instead of reading from the Android device, I'd have them login and pull them from the gmail server myself? Hm.. That's a possibility if I can't pull them directly. – Brayden Nov 29 '11 at 20:56
  • That's correct - your app can remember the login info locally and check the gmail server at any time. Would also work with Exchange and other MAPI providers. POP3 accounts would also be an option, but requires a different library and handling logic. – Matt H Nov 29 '11 at 20:59
  • Also, JMapi isn't available yet, it says currently in development. But still, thanks for the idea. – Brayden Nov 29 '11 at 20:59
  • Sorry, I meant imap - drat these acronyms. You want IMAP, not mapi. Should already have it - com.sun.mail.imap – Matt H Nov 29 '11 at 21:03
  • @MattH: There are no `com.sun` classes in Android – CommonsWare Nov 30 '11 at 01:00

1 Answers1

2

The Java Mail API works really well for interacting with IMAP and POP3 mail servers and I have had success accessing GMAIL accounts with it. Looking over the API, I don't see anything that would keep it from running on Android. I recommend that you give it a try: http://www.oracle.com/technetwork/java/javamail/index-138643.html

Bob Kuhar
  • 10,838
  • 11
  • 62
  • 115
  • This is exactly what I ended up using. Thanks! Also, you're correct, works flawlessly on Android so far. – Brayden Mar 30 '12 at 18:47
  • @Brayden , It's good. But when user disable POP3 and IMAP, your app will not work. But even though when you disable them, the Gmail provided by Google still works well. So I think there is a better solution than IMAP or POP3. – Stony Dec 24 '13 at 03:21