daily pastebin goal
72%
SHARE
TWEET

Untitled

a guest Jan 16th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top