You are here

Sound recorder

Sound recorder.

This is the default Sound recorder provided with Android SDK 1.0.

Sound recorder

See Android documentation

To record sound, use the following code:

Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, ACTIVITY_RECORD_SOUND);

To identify the result, we have defined the following constant:

private static final int ACTIVITY_RECORD_SOUND = 1;

Upon returning successfully, the sound recorder returns an URI to the newly created sound file in the content provider. Use the following code in your activity to view the returned URI in the log file:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);
	
	switch (requestCode) {
	case ACTIVITY_RECORD_SOUND:
		Log.i(TAG, data.getDataString());
		break;
	}
}

You can pass this URI to the MediaPlayback activity.

AttachmentSize
soundrecorder1.png15.42 KB