2011-07-18 5 views
3

我的問題很簡單。我想在我的活動打開隨機文件管理器使用這種方法:Implicite Intent其中打開文件管理器

private void openFile() { 
    Intent intent = new Intent(Intent.ACTION_VIEW); 
    intent.setData(Uri.parse("file://")); 
    startActivity(intent); 
} 

但它不工作。每當我收到此錯誤:

ERROR/AndroidRuntime(9107): android.content.ActivityNotFoundException: No Activity found to handle Intent... 

有什麼問題?有必要在AndroidManifest中寫一些代碼嗎?

感謝您的幫助。

+2

您的URI不完整。這就是爲什麼android無法找到要打開的活動。 – Suchi

+0

已解決的問題 - 我用ACTION_GET_CONTENT和intent.setType(「file/*」)試試這個,它的功能非常完美:) – west44

回答

0

您可以使用此操作瀏覽文件。

Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
    intent.setType("file/*"); 
    startActivity(intent); 
相關問題