private synchronized void stopRecording() { if (soundRecorder == null || !soundRecorder.isRecording()) { return; } setViewsToNotRecordingState(); try { soundRecorder.stop(); Uri uri = soundRecorder.getPath(); setResult(Activity.RESULT_OK, new Intent(Intent.ACTION_PICK, uri)); } catch (IOException e) { Log.e("CATROID", "Error recording sound.", e); Toast.makeText(this, R.string.soundrecorder_error, Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_CANCELED); } }