Guest User

Untitled

a guest
Jan 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public void mostrarPDF(String nombPdf, Context context) {
  2. Toast.makeText(context, "Visualizando documento", Toast.LENGTH_LONG).show();
  3.  
  4. // Así va correctamente la dirección AQUI
  5. String dir = Environment.getExternalStorageState()+ "/Mi App/pdf/" + nombPdf;
  6. File arch = new File(dir);
  7.  
  8. Intent intent = new Intent(Intent.ACTION_VIEW);
  9. intent.setDataAndType(Uri.fromFile(arch), "application/pdf");
  10. intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  11. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12. try {
  13. context.startActivity(intent);
  14. } catch (ActivityNotFoundException e) {
  15. Toast.makeText(context, "No existe una aplicación para abrir el PDF", Toast.LENGTH_SHORT).show();
  16. }
  17. }
Add Comment
Please, Sign In to add comment