Tuesday, June 2, 2009

Android Permissions and Audio

Found a list of all possible permissions:


would be nice if when you were trying to do something without permission it would tell you which one was missing.

Given that the example MediaRecorder code in the Android docs didn't work I was forced to search the Google Android Group for tips, and found this post with code that worked.

The challenge was then to see if the sound was being stored and I eventually found that it was when I pulled the sound file off Android with (of course I had to get the eclipse emulator to load the relevant sdcard by adjusting the launch configuration first):

./adb pull /sdcard/test.3gpp test.mp3

again the emulator seems to be available for attachment randomly ... usually the following returns nothing:

samuel-josephs-computer-2:tools samueljoseph$ ./adb devices
List of devices attached
emulator-5554    device

I did find a good summary of SD Card creation for Android.  The next challenge was to load the sound file back from the file system in order to play it, and I worked out how to store the file in the applications file space rather than within the sd card.  I am now storing the file in a sub-directory of the application space and reloading in an activity context like this (excluding all the exception handling):

String filename = "test.3gpp";
File dir = this.getDir("sounds", MODE_WORLD_READABLE);
File file = new File(dir, filename);
FileInputStream is = new FileInputStream(file);
MediaPlayer mMediaPlayer = new MediaPlayer();

So that was pleasantly simple.

1 comment:

sudheerkarumanchi said...

Hi, Your article is nice!

I am working with sending audio files from android to ip camera. I am using an ip camera from axis communications. In their api they are using http://ipadress/axis-cgi/audio/transmit.cgi

the method is post and there are no arguments to this cgi.

Can you help me in this problem, how can i send a file from android to ip camera using the above syntax over http request.

thanks & regards,