12-19 12:10:58.014: I/dalvikvm(250): threadid=7: reacting to signal 3
12-19 12:10:58.014: I/dalvikvm(250): Wrote stack trace to '/data/anr/
traces.txt'
12-19 12:14:41.104: E/MediaRecorder(282): start failed: -1
12-19 12:14:41.104: E/AudioRecordTest(282): start() failed
12-19 12:14:41.114: E/MediaRecorder(282): stop called in an invalid
state: 0
12-19 12:14:41.114: E/AudioRecordTest(282): stop() failed

I am getting these errors in logcat.

I thought, am getting error because I am using emulator, but I tries
with Sony Xperia X10, still I am geting 0. Can any help me to get out
of this problem...

Here is my code
------------------------------------------------------------------------------

public class HelloAndroid extends Activity {
protected int text;


    /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnGetDecibels;

btnGetDecibels = (Button) findViewById(R.id.btnGetDecibels);
final TextView tv = new TextView(this);
final String LOG_TAG = "AudioRecordTest";
final String mFileName = null;


final MediaRecorder mRecorder = new MediaRecorder();



btnGetDecibels.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{

     mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
try {
                    mRecorder.prepare();
                } catch (IllegalStateException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
try {
     mRecorder.start();
} catch (Exception e) {
Log.e(LOG_TAG, "start() failed");
}


     double amp = 0.0;
mRecorder.getMaxAmplitude();
amp = mRecorder.getMaxAmplitude() / 2700.0;
try {
     mRecorder.stop();
     mRecorder.release();
} catch (Exception e) {
Log.e(LOG_TAG, "stop() failed");
}

tv.setText(" Amplitude:"+amp);
setContentView(tv);
}
});
}
}
----------------------------------------------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to