2012-10-18 48 views

回答

1

使用媒體文件路徑創建ACTION_VIEW意圖,幷包含要播放的媒體類型。

String audioPath = "path/to/audio.mp3"; 

Intent intent = new Intent(); 
intent.setAction(android.content.Intent.ACTION_VIEW); 

// set the data and type, for movies this would be video/* 
intent.setDataAndType(Uri.parse(audioPath), "audio/*"); 
getContext().startActivity(intent); 

您不必設置類型,但我會建議這樣做。設置類型會將活動限制爲知道如何處理給定類型的活動。

相關問題