I am trying to trigger audio recording on Android 2.2.1 (Samsung Galaxy POP device) using the following code:
private static final int ACTIVITY_RECORD_SOUND = 1;
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, ACTIVITY_RECORD_SOUND);
This function successfully starts the recorder. As a result of my work, I do the following:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
case ACTIVITY_RECORD_SOUND:
data.getDataString();
break;
}
}
}
After the recording is complete, I will return to the audio recorder, which returns the control to the onActivityResult method, as expected, but my resultCode is always 0 (this is Activity.RESULT_CANCELED), and my data is zero. Did I miss something? Please help me with this. This works on the emulator, but not on the device. Thanks in advance.
source
share