Question

I want to launch an default audio recording app using intent just by clicking button in android. So how can i do this.

Basically i want to do same as video recording for video recording i have following code.

Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(imageToStore));
startActivityForResult(intent, CAPTURE_VIDEO);

And for Audio recording i have following code.

Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(imageToStore));
startActivityForResult(intent, CAPTURE_AUDIO);

When i press button to capture video it is opening default camera and i am able to capture video but i am not able to capture audio as it is not opening default audio recording. Does anyone know how to solve this issue.

I have tried following code link but not working.

link1

link2

Was it helpful?

Solution

Yes you are on right path but if you are running in real device then make sure that default android recording app is installed and running, try first with emulator or in some other device if you have and then check.

Your code is perfect only i did not see any error in this.

OTHER TIPS

You can try this

public static final int ACTIVITY_RECORD_SOUND = 0;
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); 
startActivityForResult(intent, ACTIVITY_RECORD_SOUND);

Try this in your Manifest file :

    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top