0
在我的android應用程序中,我需要一個文件選取器,只選擇圖像和文檔。我已經實現了,但它會選擇像其他文件像videos.I只需要選擇文件,如PDF,Excel, TXT等..和圖像和所有那些文件大小5MB.Below是我目前使用的代碼。Android:文檔和照片選擇器的目的
final String[] ACCEPT_MIME_TYPES = {"application/*", "image/*", "text/*" };
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_MIME_TYPES, ACCEPT_MIME_TYPES);
//intent.setType("file/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"),FILE_SELECT_CODE);
} catch (Exception ex) {
System.out.println("browseClick :"+ex);//android.content.ActivityNotFoundException ex
}
我沒有我在做什麼錯在這裏,使選擇挑選視頻和othere files.Please幫我解決這個問題。
'intent.setType(「*/*」);'' – greenapps