2011-05-09 78 views

回答

2

这里展示了如何打开PDF文件阅读一些代码:

private void openBook() { 
    File file = new File(mRealPath); 
    Uri path = Uri.fromFile(file); 
    Intent intent = new Intent(Intent.ACTION_VIEW); 
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    intent.setDataAndType(path, getString(R.string.application_type)); 
    try { 
     startActivity(intent); 
    } catch (ActivityNotFoundException e) { 
     Toast.makeText(FirstTab.this, 
     getString(R.string.no_application_found), 
     Toast.LENGTH_SHORT).show(); 
    } 
}