簡體   English   中英

使用意圖從SD卡中選擇音頻文件而不會使其播放

[英]choose audio file from sd card using intent without causing it to play

我想使用意圖選擇音頻文件,但是當我嘗試選擇音頻文件時,默認的音樂播放器會啟動該音頻,因此我不希望在選擇音頻時播放音頻文件,因此不勝感激。

我的代碼是

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_GET_CONTENT);

            intent.addCategory(Intent.CATEGORY_OPENABLE);

            intent.setType("audio/mp3/*");

            startActivityForResult(intent, 0);

試試這個代碼:

                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_VIEW);
                        File file = new File(path);
                        intent.setDataAndType(Uri.fromFile(file), "audio/*");
                        startActivity(intent);

編輯:當然,文件是您要播放的音頻...希望對您有所幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM