Generally, if you need a permission, you'll see an error message in the log output. I'm pretty sure AudioFlinger outputs an error message if an app tries to record without the permission.
Anything that might lead to privacy or security issues generally requires special permission from the user. In the media framework, this includes recording audio, accessing the camera, and modifying system volume controls. On Dec 9, 9:07 pm, Lei <[EMAIL PROTECTED]> wrote: > wow! > > Thank you, mnj. > It works well now. > > And one more question, how can I know that where it needs a > permission? > > Regards, > Lei. > > On Dec 10, 12:36 pm, mnj <[EMAIL PROTECTED]> wrote: > > > Hi, > > > Did you set the below permission in AndroidManifest.xml > > > <uses-permission android:name="android.permission.RECORD_AUDIO" /> > > > Regards, > > Manoj > > > On Dec 10, 9:30 am, Lei <[EMAIL PROTECTED]> wrote: > > > > Hi all, > > > I want to record the audio from the micphone. But I failed. > > > I reference the document. And the link > > > is:http://code.google.com/android/toolbox/apis/media.html > > > > I got the file. Its size is always 1666B. I played it but hear > > > nothing. > > > > Thanks in advance. > > > Regards, > > > Lei > > > > The code is : > > > > public class MediaRecorderDemo extends Activity { > > > > private static final String TAG = "MediaPlayerDemo"; > > > private MediaPlayer mMediaPlayer; > > > private String path; > > > > /** Called when the activity is first created. */ > > > > @Override > > > public void onCreate(Bundle savedInstanceState) { > > > super.onCreate(savedInstanceState); > > > setContentView(R.layout.main); > > > > mPlay = (Button) findViewById(R.id.play); > > > mStart = (Button) findViewById(R.id.start); > > > mStop = (Button) findViewById(R.id.stop); > > > > mPlay.setOnClickListener(mPlayListener); > > > mStart.setOnClickListener(mStartListener); > > > mStop.setOnClickListener(mStopListener); > > > } > > > > @Override > > > protected void onDestroy() { > > > super.onDestroy(); > > > // TODO Auto-generated method stub > > > if (mMediaPlayer != null) { > > > mMediaPlayer.release(); > > > mMediaPlayer = null; > > > } > > > > } > > > > private OnClickListener mStopListener = new OnClickListener() { > > > public void onClick(View v) { > > > recorder.stop(); > > > recorder.release(); > > > } > > > }; > > > > private OnClickListener mPlayListener = new OnClickListener() { > > > public void onClick(View v) { > > > try { > > > path = "/sdcard/audio4"; > > > if (path == "") { > > > // Tell the user to provide an audio file URL. > > > Toast > > > .makeText( > > > MediaRecorderDemo.this, > > > "Please edit MediaPlayer_Audio > > > Activity, " > > > + "and set the path > > > variable to your audio file path." > > > + " Your audio file > > > must be stored on sdcard.", > > > Toast.LENGTH_LONG).show(); > > > > } > > > mMediaPlayer = new MediaPlayer(); > > > mMediaPlayer.setDataSource(path); > > > mMediaPlayer.prepare(); > > > mMediaPlayer.start(); > > > > } catch (Exception e) { > > > Log.e(TAG, "error: " + e.getMessage(), e); > > > } > > > > } > > > }; > > > > private OnClickListener mStartListener = new OnClickListener() { > > > public void onClick(View v) { > > > String path = "/sdcard/audio4"; > > > > //ContentResolver contentResolver; > > > recorder.setAudioSource(MediaRecorder.AudioSource.MIC); > > > recorder.setOutputFormat > > > (MediaRecorder.OutputFormat.THREE_GPP); > > > > > > recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); > > > recorder.setOutputFile(path); > > > > recorder.prepare(); > > > recorder.start(); > > > } > > > }; > > > > private Button mPlay; > > > private Button mStop; > > > private Button mStart; > > > private MediaRecorder recorder = new MediaRecorder(); > > > > }- Hide quoted text - > > > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

