Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

android - Delete Gmail emails programmatically

I am working on an application in which I am accessing Gmail emails in my own application, but I am unable to delete those emails through their id. How can I do this?

delete.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        try {
            Uri uri = Uri.parse((new StringBuilder()).append(
                "content://gmail-ls/messages/").append(account_name).append("/").append(mail_id).toString());
            getContentResolver().delete(uri, null, null);
            Toast.makeText(cont, "Deleted", Toast.LENGTH_SHORT).show();

            // getContentResolver().delete(
            // Uri.parse("content://gmail-ls/conversations/"
            // + account_name + "/" + mail_id + ""), null,
            // null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Apart from whatever your problem seems to be (you did not specify it, but it sounds like you can read the mails?), you cannot really rely on this feature.

The last version for which this works is 2.3.4.1 See: http://groups.google.com/a/googleproductforums.com/forum/#!category-topic/gmail/reading-and-receiving-messages/XD0C4sw9K7U

In the near future, we are going to make a change which may affect your apps. Historically, the Gmail app has exposed an undocumented Content Provider, protected by a non-public Permission value, that allows apps granted permission by the user to read users' email and also execute live queries. We have determined, as part of our continuous effort to improve the level of security of Gmail, that this API does not meet modern security standards. Therefore, we will be disabling it in the next update to Gmail on Android devices running Froyo and later releases.

And secondly, I don't think this method was more then just read permission.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...