我做了一个android应用程序,现在,这个应用程序需要阅读电子邮件。我找到了这段代码:
protected ArrayList<Mail> doInBackground(Void... params) {
ArrayList<Mail> mails = new ArrayList<Mail>(32);
boolean finish = false;
try {
String direcCompleta = URI_PREFIX + email;
Uri a = Uri.parse(direcCompleta);
Cursor cCursor = resolver.query(a, null, null , null, null);
while (cCursor.moveToNext() && (! finish)) {
finish = fromTime.before(new Date(cCursor.getLong(1)));
if (! finish){
String conv_id = cCursor.getString(cCursor.getColumnIndex("_id"));
Uri uri = Uri.parse(URI_PREFIX + email + "/" + conv_id + "/messages");
Cursor mCursor = resolver.query(uri, MESSAGE_PROJECTION, null, null, null);
while (mCursor.moveToNext() && (! finish)){
long mtime = mCursor.getLong(4);
finish = fromTime.before(new Date(mtime));
if (! finish){
mails.add(new Mail(mCursor.getString(0), mCursor.getString(2), mCursor.getString(1), mCursor.getString(4), mtime));
}
}
}
}
} catch (Exception ex){
Log.e("GmailReadApp", ex.toString());
mails.add(new Mail(null, null, ex.toString(), ex.toString(), 0));
}
return mails;
}
但 cCursor 为空。我在应用程序中有我的邮件帐户:“电子邮件”,因为我使用 android sdk,它没有应用程序:“GMAIL”。而且android sdk没有市场。
有人可以帮助我吗?谢谢。(无论是用于 gmail、yahoo、hotmail ......)