2016-07-06 56 views
0

我的應用程序將文件保存在默認的下載文件夾中。這由Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)決定。如何啓動默認的Android下載活動或應用程序?

現在我想打開你的默認Android下載活動或應用程序,所以用戶看到我的新文件的下載文件夾。

+2

除非您使用'DownloadManager',否則您的文件將不會出現在下載應用程序中,至少在大多數Android版本中,IIRC。下載應用程序傳統上只顯示它下載的文件,而不顯示任何給定的「Downloads /」目錄的全部內容。 – CommonsWare

回答

1

請試試這個方法。

public void openFolder() { 
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
    Uri uri = Uri.parse(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)); 
    intent.setDataAndType(uri, "resource/folder"); 
    startActivity(Intent.createChooser(intent, "Open folder")); 
} 
1

我相信這是你正在尋找的代碼:

Intent intent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); 
startActivity(intent); 
相關問題