Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:42:54+00:00 2026-05-23T07:42:54+00:00

I am developing an app which is already existing but I am developing just

  • 0

I am developing an app which is already existing but I am developing just to learn. I am developing a GMail client app for Android. I tried with Content Observer but was unable to find the Content Provider URI for GMail Inbox. I am trying other way by setting ua a client. My client is set up, but i don’t know how to instantiate this client to hit the GMail server.

Following are my code:

GMailInbox.java

package com.tyco.gmailApp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class GmailInbox extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //GmailObserver go = new GmailObserver();
        //this.getApplicationContext().getContentResolver().registerContentObserver(Uri.parse("content://imap.gmail.com"), true, go);

        Intent myService = new Intent(this,GMailService.class);
        myService.putExtra("user", "rj@gmail.com");
        myService.putExtra("password", "brooklyn");
        startService(myService);
    }
}

GMailService.java

package com.tyco.gmailApp;


import java.util.Properties;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.view.inputmethod.InputMethodSession;
import android.view.inputmethod.InputMethod.SessionCallback;
public class GMailService extends Service
{

    private String mailhost = "imaps.gmail.com"; 
    private String user; 
    private String password; 

    @Override
    public IBinder onBind(Intent intent){
        return null;
    }

    @Override
    public void onCreate(){
        super.onCreate();


    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);
        this.user = intent.getStringExtra("user"); 
        this.password = intent.getStringExtra("password");; 
        Properties props = new Properties();
        props = System.getProperties();
        props.setProperty("mail.store.protocol", "imaps");
        props.setProperty("mail.imaps.host", mailhost); 
        props.put("mail.imaps.auth", "true"); 
        props.put("mail.imaps.port", "993"); 
        props.put("mail.imaps.socketFactory.port", "993"); 
        props.put("mail.imaps.socketFactory.class", 
                  "javax.net.ssl.SSLSocketFactory"); 
        props.put("mail.imaps.socketFactory.fallback", "false");
        props.put("mail.imaps.socketFactory.fallback", "false");
        props.setProperty("mail.imaps.quitwait", "false"); 


// I Don't Know what to do here



    }




}

I don’t know what to do after collecting all info into properties object. Please suggest something.

Regards,
Rahul Jaiswal

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:42:55+00:00Added an answer on May 23, 2026 at 7:42 am

    Add this code to connect with mail server

    Session session = Session.getDefaultInstance(props, null);
        try{
            Store store = session.getStore("imaps");
            store.connect(mailhost, mailid,password);    
            Folder folder = store.getFolder("INBOX");
            folder.open(Folder.READ_ONLY);
            int count=folder.getUnreadMessageCount();
            Message  message[] = folder.getMessages();
            for (int i=0, n=message.length; i<n; i++) {
                    System.out.println("subject " +message[i].getSubject());
            }
          }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hy, I'm developing a Grails app which has to communicate with an existing Java
I'm developing a web app for which the client wants us to query their
I am developing an app using android OS for which I need to know
I'm developing an Android app (Android 1.6), but this is probably a more general
I am developing an android app. My client has got Motorola Atrix. I designed
I'm developing an Android app which needs to connect to a .NET SOAP web
I'm developing an Android project which currently has 4 packages: com.myapp.app.activities com.myapp.app.db com.myapp.app.ws com.myapp.app.utils
I'm developing an app which has a large amount of related form data to
I am developing a web app which requires a username and password to be
I am developing an app in which I have a table. In the table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.