File file = new File(s);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
try {
startActivity(intent);
}
catch(Exception e)
{
file.delete();
downloadFile(file);
}
I am trying to Open the PDF using External Application in Android, if the File is fully downloaded it will open and show the PDF File. If the File is empty or corrupted i want to delete the file and re Download it.
But i am not able to handle
the Exception "The Document can't be Opened".
(s)
. You think the value ofs
is irrelevanf? – greenapps 19 hours ago