Thanks a lot!

On Dec 10, 1:20 pm, mnj <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Check the link  http://code.google.com/android/devel/security.html
> andhttp://code.google.com/android/reference/android/Manifest.permission....
>
> "A central design point of the Android security architecture is that
> no application, by default, has permission to perform any operations
> that would adversely impact other applications, the operating system,
> or the user. This includes reading or writing the user's private data
> (such as contacts or e-mails), reading or writing another
> application's files, performing network access, keeping the device
> awake, etc"
>
> Regards,
> Manoj
>
> On Dec 10, 10:07 am, 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 -- 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to