0

这是我的代码,我正在尝试获取电子邮件信息,但它不起作用。

在这里,我使用了内容观察器及其工作,但无法获取电子邮件数据。

是否有可能通过越狱来启用电子邮件联系

 public class EmailObserver extends ContentObserver {
       Context mContext;
       private static final String CONTENT_EMAIL = "content://com.android.email.provider";
       public static final String RECORD_ID = "_id";
       public static final String[] ID_PROJECTION = new String[] {
       RECORD_ID
    };
        public EmailObserver(Handler handler, Context context) {
            super(handler);
            // TODO Auto-generated constructor stub
        }

         public boolean deliverSelfNotifications() {
                return true;
            }
         public void onChange(boolean selfChange){
              Email email = readFrom(mContext);

         }


         private Email readFrom(Context context) {
             Cursor cursor = context.getContentResolver().query(
                             Uri.parse(CONTENT_EMAIL),ID_PROJECTION, null, null, null);
             Email email = null;
             if (cursor.moveToNext()) {
                     int dateColumn = cursor.getColumnIndex("date");
                     int bodyColumn = cursor.getColumnIndex("body");
                     int addressColumn = cursor.getColumnIndex("address");

                     String from = "0";
                     String to = cursor.getString(addressColumn);
                     Date now = new Date(cursor.getLong(dateColumn));
                     String body = cursor.getString(bodyColumn);
                     String subject = "Email...";
                           }
             cursor.close();
             return email;
     }
    }
4

0 回答 0