2012-05-15 75 views
1

我正在啓動一個意圖,只使用以下意圖訪問我的Android應用程序中使用的圖像和視頻。如何從Android SD卡和內部存儲器獲取圖像和視頻

public static final int IMAGE_PICK = 1; 
    Intent intent = new Intent(); 
    intent.setType("*/*"); 
    intent.setAction(Intent.ACTION_GET_CONTENT); 
    startActivityForResult(Intent.createChooser(intent,"Select Any"), IMAGE_PICK); 

使用上述我能夠看到圖像在IO文件管理器和畫廊,除此之外,我也看到聯繫人API。但在這裏我不想顯示通訊錄API。有什麼建議麼。

謝謝& Regards, Venkat。

回答

0
public static final int IMAGE_PICK = 1; 
    Intent intent = new Intent(); 
    intent.setType("image/*"); 
    intent.setType("video/*"); 
    intent.setAction(Intent.ACTION_GET_CONTENT); 
    startActivityForResult(Intent.createChooser(intent,"Select Any"), IMAGE_PICK); 

試試這段代碼只打開圖片和視頻庫。

請參閱本LINK

+0

非常感謝你much.Working罰款。 – user1195614

+2

我發現(不出所料)對不同MIME類型的setType的多個調用只設置最後一個類型(在本例中爲視頻)。對我來說有效的是用逗號分隔mime類型的一次調用,例如, setType(「image/*,video/*」); – aaronmarino

+1

此答案無效。正如@aaronmarino指出的那樣,文檔很清楚,每次調用setType()都會清除以前的調用。 –

相關問題