如何将文件添加到Android项目,它部署到该设备,然后再打开它? [英] How to add a file to an Android project, deploy it to the device, and then open it?

查看:101
本文介绍了如何将文件添加到Android项目,它部署到该设备,然后再打开它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse(太阳神)一个Android(2.2)项目。我想一个MP3文件添加到项目中,这样的MP3文件部署到设备与应用程序一起。

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.

然后我想打开该文件作为文件对象,这意味着我需要知道的完整路径(?),以文件的设备上,但我不知道路径如何在Android中指定。

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.

推荐答案

显然有是prevents WAV播放Froyo的一个bug。
音频文件应放在资源/生项目的目录。然后使用ID进行播放(或试图播放)

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();


信息:<一href="http://developer.android.com/guide/topics/media/index.html">http://developer.android.com/guide/topics/media/index.html
示例(MP3):<一href="http://www.helloandroid.com/tutorials/musicdroid-audio-player-part-i">http://www.helloandroid.com/tutorials/musicdroid-audio-player-part-i


Info: http://developer.android.com/guide/topics/media/index.html
Example (mp3): http://www.helloandroid.com/tutorials/musicdroid-audio-player-part-i

这篇关于如何将文件添加到Android项目,它部署到该设备,然后再打开它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆