I have to following code to launch and the audio recorder on Android:
Using java Syntax Highlighting
- final Intent recordSoundIntent = new Intent("android.provider.MediaStore.RECORD_SOUND");
- String fileName = Environment.getExternalStorageDirectory() + File.separator + UUID.randomUUID() + ".3gpp";
- recordSoundIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(fileName)));
- startActivityForResult(Intent.createChooser(recordSoundIntent, getString(R.string.record_sound_chooser)), INTENT_SOUND_RECORDING);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
And the following code to save the location to the newly recorded audio:
Using java Syntax Highlighting
- Uri uri = data.getData():
- soundRecording.setLocation(uri.toString());
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
And this code to play (it works with no problem):
Using java Syntax Highlighting
- MediaPlayer mp = new MediaPlayer();
- mp.setDataSource(soundRecording.getLocation());
- mp.prepare();
- mp.start();
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
My problem is the following:
1. My filename (fileName) has no effect, the Uri returned from data.getData() returns in my last test run: content://media/external/audio/media/41. However, this file is created on my sdcard: recording34485.3gpp. If it is not possible to set custom location upon creating sound it is the location to this file I would like.
2. I want to mail this recording using the ACTION_SEND, but I can't attach the audio file, I guess because soundRecording.getLocation() points to content://media/external/audio/media/41 and not recording34485.3gpp:
File file = new File(soundRecording.getLocation());
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
Can anyone help me?
Best regards
Per Jansson

