2011-05-09 77 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(); 
    } 
}