Change back ground color according to Voice intensity
<p>Currently my Code is detecting voice intensity (using media recorder) i want to change background color to white when there is no voice , when user speak then background color must b light or dark according to voice intensity </p>

<p>here is my code im having problem to make color light and dark according to voice intensity .</p>

<pre><code>final Runnable updater = new Runnable(){

    public void run(){          
        updateTv();
        TextView tv = (TextView)findViewById(R.id.status);
        int tvStatus=  Integer.parseInt(tv.getText().toString());
        if(tvStatus &gt; 1000)
            updateBackground();
        else
            mScreen.setBackgroundColor(Color.WHITE);
    };
};

final Handler mHandler = new Handler();

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    mStatusView = (TextView) findViewById(R.id.status);
    mScreen = (LinearLayout) findViewById(R.id.myScreen);

    if (runner ==  null)
    { 
        runner = new Thread(){
            public void run()
            {
                while (runner != null)
                {


                    try
                    { 
                       Thread.sleep(1000);
                        Log.i("Noise", "Tock");
                    } catch (InterruptedException e) { };
                    mHandler.post(updater);
                }
            }
        };
        runner.start();
        Log.d("Noise", "start runner()");
    }
}

private void updateBackground()
{

     int ampl  =(int)getAmplitude();
    int color;
    Random rnd = new Random(); 

 mScreen.setBackgroundColor(

         color );

}
public void onResume()
{
    super.onResume();
    startRecorder();
}

public void onPause()
{
    super.onPause();
    stopRecorder();
}

public void startRecorder(){
    if (mRecorder == null)
    {
        mRecorder = new MediaRecorder();
        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 (java.io.IOException ioe) {
           android.util.Log.e("[Monkey]", "IOException: " + android.util.Log.getStackTraceString(ioe));

        }catch (java.lang.SecurityException e) {
            android.util.Log.e("[Monkey]", "SecurityException: " + android.util.Log.getStackTraceString(e));
        }
        try
        {           
            mRecorder.start();
        }catch (java.lang.SecurityException e) {
            android.util.Log.e("[Monkey]", "SecurityException: " + android.util.Log.getStackTraceString(e));
        }

        //mEMA = 0.0;
    }

}
public void stopRecorder() {
    if (mRecorder != null) {
        mRecorder.stop();       
        mRecorder.release();
        mRecorder = null;


    }
}

public void updateTv(){
    mStatusView.setText(Integer.toString((getAmplitude())));
}
public double soundDb(double ampl){
    return  20 * Math.log10(getAmplitudeEMA() / ampl);
}
public int getAmplitude() {
    if (mRecorder != null)
        return  (mRecorder.getMaxAmplitude());
    else
        return 0;

}
</code></pre>
