Send email as Feedback on Android

-1

I need to implement the functionality of feedback in Android, that the user to trigger the action is sent an email, with the app available, but pre-configured with the email to receive the email.

    
asked by Webserveis 12.11.2018 в 19:05
source

1 answer

0

Searching for SO I've found the easiest solution.

The best option is to use compatibility library ShareCompat to create the intent.

ShareCompat.IntentBuilder.from(activity)
    .setType("message/rfc822")
    .addEmailTo("[email protected]")
    .setSubject("titulo del email")
    .setText("cuerpo del mensaje")
    //.setHtmlText(body) //Si se quiere usar HTML en el cuerpo del mensaje
    .setChooserTitle("Enviar Feedback con")
    .startChooser();

If you want to detect if there is a compatible app to send the email, replace the .startChooser() with .createChooserIntent()

ShareCompat.IntentBuilder.from(activity)
    .setType("message/rfc822")
    .addEmailTo("[email protected]")
    .setSubject("titulo del email")
    .setText("cuerpo del mensaje")
    //.setHtmlText(body) //Si se quiere usar HTML en el cuerpo del mensaje
    .setChooserTitle("Enviar Feedback con")
    .createChooserIntent();

    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    } else { /*imposible enviar feedback*/}

If you want to know more about the ShareCompat I leave tutorial Sharing Content The Easy Way using ShareCompat

    
answered by 12.11.2018 в 19:05