/**
* Get PDF file Intent
*/
public Intent getPdfFileIntent(String path){
Intent i = new Intent(Intent.ACTION_VIEW);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
Uri uri = Uri.fromFile(new File(path));
i.setDataAndType(uri, "application/pdf");
return i;
}
public void onClick(View v) {
//You need to open another thread to download file ,
//so that it cannot disturb the main UI thread.
final HttpDownloader loader = new HttpDownloader(getApplicationContext());
int result = loader.download("http://xxx.pdf", "Tian/", "t0.pdf");
Log.d("PDFActivity.java","Download result: "+result);
if(result == 0 || result == 1){ // Success,open it
Intent intent = getPdfFileIntent("/mnt/sdcard/Tian/t0.pdf");
startActivity(intent);
}
}
});
/*** Get PDF file Intent*/public Intent getPdfFileIntent(String path){Intent i = new Intent(Intent.ACTION_VIEW);i.addCategory(Intent.CATEGORY_DEFAULT);i.addFlags(Intent.FLAG_ACTIVITY_NEW_T