c-an
c-an

Reputation: 4090

How can I get data from e-mail applications such as Gmail, Hotmail, Yahoo, etc?

I implemented sendEmailTo(email) like this to show email applications & choose & go to the app.

    private fun sendEmailTo(email: String?) {
        val intent = Intent(Intent.ACTION_SENDTO) // it's not ACTION_SEND
        intent.type = "text/plain"
        intent.putExtra(Intent.EXTRA_SUBJECT, "Subject of email")
        intent.putExtra(Intent.EXTRA_TEXT, "Body of email")
        intent.data = Uri.parse("mailto:$email") // or just "mailto:" for blank
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) // this will make such that when user returns to your app, your app is displayed, instead of the email app.
        startActivity(intent)
    }

I'd like to save the data that user wrote before they leave the email app so that when they return, they can keep writing, not from zero again.

Gmail has that kind of functionality - transient storage by default. When I press the back button, the app saved the data into transient storage. So, gmail is Okay. But I checked with hotmail and yahoo. And they don't have that sort of functionality and the user needs to write from 0 because the previous mail is gone already.

So, I'd like get the last email data so that the user can keep writing after they reopen the application. How can I do that?

Upvotes: 0

Views: 78

Answers (1)

Morrison Chang
Morrison Chang

Reputation: 12121

You don't

Correctly saving drafts is a function of the email app. If the app fails to correctly implement the behavior, then no third party can make it work as you don't know what the user changed in the text.

Upvotes: 4

Related Questions