The problem is when the file is sent because, is not adding the extension to the file (Pdf)
This is my code to send email:
@Override
public void onClick(View v) {
try {
final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
emailIntent.setType("application/pdf");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
Uri prueba = Uri.parse("android.resource://" + getPackageName() +"/"+R.raw.tecnolite);
emailIntent.putExtra(Intent.EXTRA_STREAM, prueba);
startActivity(Intent.createChooser(emailIntent, "Enviando correo..."));
} catch (Throwable t) {
Toast toast = Toast.makeText(getApplicationContext(), "Error al enviar el correo", Toast.LENGTH_SHORT);
toast.show();
}
}
An android resource belonging to one package is private to that package and can not be accessed by another process. In this case, the email app can not access your app’s resources. You either need to copy the resource into external memory, or implement a
ContentProviderfor the email app to load your stream. ThisContentProviderwould also identify the correct mime-type for your attachment.