0
我試圖用一個開關盒來選擇以.txt結尾的文件,以及一個結束.pdf的文件,我一直在練習開關盒,但實際上並未實現在這種情況下,我的代碼是如何在onFileClick中使用開關盒android
private void onFileClick(Option o)
{
Uri path = Uri.parse(o.getPath());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(FileChooser.this,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
我想要實現的URI的txt文件,.pdf和其他人在的情況下,請helpme,並感謝你
非常感謝你做,效果真的不錯,我不知道,在字符串值的切換不是在Android的完全支持,還有一個問題,我必須替換/ pdf來打開.txt文件? [code] intent.setDataAndType「application/pdf」... – 2013-03-05 05:03:20