Reading Gmail mails using android SDK

I want to read Gmail mails in my own android app. Is there anyway to do it using android sdk? If not, what are the other options? parsing gmail atom?

  • How To Get File In Assets From Android NDK
  • Android Native debug (ndk-gdb) on HTC Desire: run-as flaw?
  • Android WebView 302 Redirect - Honeycomb
  • Didn't find class on path: dexpathlist
  • ORMLite not loading child foreign fields
  • BLE Android - onConnectionStateChange not being called
  • How to make an Android view that flips between views on swipe/fling
  • What's the best way to do “application settings” in Android?
  • Cocos2d-x android can't resolved coscos2dx library
  • why do we use to connect to local web server instead of using computer ip address in android client
  • How to prevent user changing system date/time (in Android)?
  • How i can optimize this code that contain some repetitive line?
  • 2 Solutions collect form web for “Reading Gmail mails using android SDK”

    I ask and answer that question here.
    You need code (in the question there are a link) and you must understand that you shouldn’t use that undocumented provider

    Are there any good short code examples that simply read a new gmail message?

    It’s possible using the GMail API, here are some steps I found helpful.

    1. Start with the official sample to get the GMailAPI started, see here
    2. When following the instructions I found it helpful to read about the app signing here in order to get Step1+2 in the sample right.
    3. With the sample running you can use the information here to access messages. You can e.g. replace the implementation in MakeRequestTask.getDataFromApi
    4. Be sure to add at least the read-only scope for proper permissions. In the sample the scopes are defined in an array:

      private static final String[] SCOPES = { GmailScopes.GMAIL_LABELS, mailScopes.GMAIL_READONLY };

    5. My intention was to read all subjects. I used the following code (which is the adapted getDataFromApi method from the official sample):

       private List<String> getDataFromApi() throws IOException {
           // Get the labels in the user's account. "me" referes to the authentized user.
           String user = "me";
           List<String> labels = new ArrayList<String>();
           ListMessagesResponse response = mService.users().messages().list(user).execute();
           for (Message message : response.getMessages()) {
               Message readableMessage = mService.users().messages().get(user, message.getId()).execute();
               if (readableMessage.getPayload() != null) {
                   for (MessagePartHeader header : readableMessage.getPayload().getHeaders()) {
                       if (header.getName().compareToIgnoreCase("Subject") == 0) {
          return labels;
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.