Answer the question
In order to leave comments, you need to log in
How to view pdf and doc files in the application?
there is a link to the pdf file on the site, how to make it possible to view it either in your application. Or that it redirects to the pdf viewer.
nav_5 transfers to the PDF viewing program.
nav_6 to the site throws, shakes and then only offers to open it.
main activity:
} else if (id == R.id.nav_5) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.uoipd.by/files/files/studentu/raspisanie/dnevnoe/5kurs.pdf" +
""));
startActivity(browserIntent);
} else if (id == R.id.nav_6) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.uoipd.by/files/files/studentu/raspisanie/zaochnoe/Raspisanie-3k-s-21.11-po-10.12.2016%20%20.pdf" +
""));
startActivity(browserIntent);
Answer the question
In order to leave comments, you need to log in
Why don't you like the option of viewing in a third-party application?
Personally, I have this code:
try
{
Uri path = ContentProvider.getUri(getActivity(), order);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_GRANT_READ_URI_PERMISSION);
getActivity().startActivity(intent);
}
catch (ActivityNotFoundException e)
{
new AlertDialog.Builder(getActivity())
.setTitle(R.string.pdf_open_error)
.setMessage(R.string.need_pdf_application)
.setNegativeButton(R.string.close, null)
.show();
}
catch (Exception e)
{
toast(e.getLocalizedMessage());
Sentry.handleException(e);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question