A “click” basically sends a request to the server and displays the return information.
1 / find out what url to call this request (if it is a web page, see for example firebug)
2 / find out what parameters, find out if the method is GET or POST
3 / is played back programmatically.
4 / a "login phase" probably implies the use of a cookie that the server gives you, and that you must send back after each request
However, your approach is wrong. You should not try to connect directly to Google via URL connections. (Also you should use HttpClient). Moreover, query properties are not parameters. They are the headlines.
I highly recommend you start with something simpler to conveniently communicate with HTTP in java, GET, POST, parameters, headers, answers, cookies ...
Edit
After receiving the response, you will want to verify that
response.getStatusLine().getStatusCode() < 400
He will tell you that the login was successful. (2xx are successful, 3xx are moving, etc. 4xx are errors in the request, 5xx are errors on the server side, Gmail responds with 302 for login in order to suggest redirection to incoming messages). Then you will notice that the “Set-Cookie” response has a specific header containing the cookie that you want for future connections in order to:
String cookie = response.getFistHeader("Set-Cookie");
Then you can call a request to get contacts:
HttpGet getContacts = new HttpGet(GMAIL_CONTACTS); getContacts.setHeader("Cookie", cookie); response = httpClient.execute(getContacts); InputStream ins = response.getEntity().getContent();
It should be something like this.