I'm very new to this, it turns out that I have an app that will send me all my data and an attachment to send it by email, but when I update my mobile to android 8 I do not have the file attached, I've put a conditional depending on the API but it sends me all the data except the attachment to gmail and I do not know why you can not attach it, the file is in the correct location.
public void enviarbaja1(){
String pdfFile= String.valueOf(new File(Environment.getExternalStorageDirectory() + "/Bajas/","Baja " + Variables.getentradanombretomadorbaja() + ".pdf" ));
Uri uri;
//Validación de acuerdo al OS.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
uri =Uri.parse(pdfFile);
} else{
uri =Uri.fromFile((new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Bajas/","Baja " + Variables.getentradanombretomadorbaja() + ".pdf" )));
}
//Instanciamos un Intent del tipo ACTION_SEND
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
//Aqui definimos la tipologia de datos del contenido dle Email en este caso text/html
emailIntent.setType("text/html");
// Indicamos con un Array de tipo String las direcciones de correo a las cuales enviar
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{emaildestino1.getText().toString()});
// Aqui definimos un email para enviar como copia
emailIntent.putExtra(Intent.EXTRA_CC, new String[]{emailcopia1.getText().toString()});
// Aqui definimos un titulo para el Email
emailIntent.putExtra(android.content.Intent.EXTRA_TITLE, emailtitulo1.getText().toString());
// Aqui definimos un Asunto para el Email
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, emailasunto1.getText().toString());
// Aqui obtenemos la referencia al texto y lo pasamos al Email Intent
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailcuerpo1.getText().toString());
// Colocamos el adjunto en el stream
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
//indicamos el tipo de dato
emailIntent.setType("application/pdf");
try {
//Enviamos el Correo iniciando una nueva Activity con el emailIntent.
startActivity(Intent.createChooser(emailIntent, "Seleccionar metodo de envio..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(generarpdfbaja.this, "No hay ninguna aplicación de correo electrónico instalada.", Toast.LENGTH_LONG).show();
}
}