I'm searching on the web how to open pdf file from server with default pdf viewer on android. What I found is download the file first then start it in intent or load it with google docs. I don't want to do all these. I just want to load it directly from server in default pdf viewer from phone. I've tried opening video url with intent and it worked. But opening pdf url with intent is not working. Below is my code;
private void openFilePDF(){
try{
Toast.makeText(getBaseContext(), "Opening PDF... ", Toast.LENGTH_SHORT).show();
Intent inte = new Intent(Intent.ACTION_VIEW);
inte.setDataAndType(
Uri.parse("http://122.248.233.68/pvfiles/Guide-2.pdf"),
"application/pdf");
startActivity(inte);
}catch(ActivityNotFoundException e){
Log.e("Viewer not installed on your device.", e.getMessage());
}
}
Is there any way that I can load pdf url in intent?
See Question&Answers more detail:os