如何将文件添加到Android项目中,将其部署到设备中,然后再打开? [英] How to add a file to an Android project, deploy it to the device, and then open it?
问题描述
然后我打开文件作为文件
对象,这意味着我需要知道设备上文件的完整路径(?),但我不知道如何在Android中指定路径。
显然,Froyo有一个BUG阻止WAV播放的错误。
音频文件应放置在项目的res / raw目录中。然后使用id来播放它(或尝试播放它)
MediaPlayer mp = MediaPlayer.create(context,R.raw.sound_file_1);
mp.start();
信息: http://developer.android.com/guide/topics/media/index.html
示例( mp3): http://www.helloandroid.com/tutorials/musicdroid- audio-player-part-i
I have an Android (2.2) project in Eclipse (Helios). I want to add an MP3 file to the project so that the MP3 file is deployed to the device along with the application.
I then would like to open the file as a File
object, which means I'd need to know the full path (?) to the file on the device, but I don't know how paths are specified in Android.
Apparently there is a bug in Froyo that prevents WAV playback.
Audio files should be placed in the "res/raw" directory of your project. Then use the id to play it (or attempt to play it)
MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1); mp.start();
Info: http://developer.android.com/guide/topics/media/index.html
Example (mp3): http://www.helloandroid.com/tutorials/musicdroid-audio-player-part-i
这篇关于如何将文件添加到Android项目中,将其部署到设备中,然后再打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!