Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void mostrarPDF(String nombPdf, Context context) {
- Toast.makeText(context, "Visualizando documento", Toast.LENGTH_LONG).show();
- // Así va correctamente la dirección AQUI
- String dir = Environment.getExternalStorageState()+ "/Mi App/pdf/" + nombPdf;
- File arch = new File(dir);
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.fromFile(arch), "application/pdf");
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- try {
- context.startActivity(intent);
- } catch (ActivityNotFoundException e) {
- Toast.makeText(context, "No existe una aplicación para abrir el PDF", Toast.LENGTH_SHORT).show();
- }
- }
Add Comment
Please, Sign In to add comment