2017-07-29 31 views

回答

0

可以使用例如从这里:

https://developers.google.com/gmail/api/quickstart/android

后来,而是要求你要问的消息,所以你需要更新的功能标签“getDataFromApi”得到的消息:

private static final long MAX_RESULTS_PER_REQUEST = 20; 
private void getDataFromApi() throws IOException { 
List<String> labelsId = new ArrayList<>(); 
labelsId.add("INBOX"); 
ListMessagesResponse response=null; 
response = mService.users().messages().list("me").setMaxResults(MAX_RESULTS_PER_REQUEST).setLabelIds(labelsId).execute(); 
List<Message> messages = response.getMessages(); 
for (Message message : messages) { 
    Message curMessage = mService.users().messages().get("me", message.getId()).execute(); 
    System.out.println("cur message==>"+curMessage);  
    } 
} 
+0

你能举个例子吗?我无法理解谷歌文档。我需要一个例子。 –

+0

@MetinTaşdeğer但是,这是完整的例子那里如何从android中的gmail API获取信息...你想要什么样的例子? – OriEng

+0

你能分享一个getDataFromApi的例子来获取消息。我不做这个例子 –

1

可以使用Content Provider API of Gmail

Android的Gmail应用程序的版本2.3.6开始(升级Froyo /姜饼) 和4.0.5(蜂窝/ ICS)包括一个新的内容提供商的API, 第三获得此第三方开发人员可以使用来检索,如姓名 和未读邮件数的标签信息,并保持更新这些信息改变

要在行动中看到这个API的例子,看看the sample app