Java android开发者-检查麦克风(或任何硬件模块)是否忙

Java android开发者-检查麦克风(或任何硬件模块)是否忙,java,android,Java,Android,我的应用程序的目标是检查是否有其他录音应用程序正在工作,或者麦克风是否正忙/正在录制。代码如下: 专用媒体记录器mRecord=null public void start() { if (mRecord == null) { mRecord = new MediaRecorder(); mRecord.setAudioSource(MediaRecorder.AudioSource.MIC);

我的应用程序的目标是检查是否有其他录音应用程序正在工作,或者麦克风是否正忙/正在录制。代码如下:

专用媒体记录器mRecord=null

public void start() {
        if (mRecord == null) {
                mRecord = new MediaRecorder();
                mRecord.setAudioSource(MediaRecorder.AudioSource.MIC);
                                    try {
                    mRecord.prepare();
                } catch (IllegalStateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                mRecord.start();
        }
}

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


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    btnCheck = (Button) findViewById(R.id.btnCheck);
    btnCheck.setOnClickListener(MainActivity.this);     

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public void onClick(View v) {


    switch (v.getId()) {
    case R.id.btnCheck:

        if (mRecord != null) {
            mRecord.stop();       
            mRecord.release();                
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);
            LayoutInflater inflater = getLayoutInflater();
            View convertView = null;
            alertDialog.setView(convertView);
            alertDialog.setTitle("You are being recorded!!!");
            alertDialog.show();
        }       

        else {

            AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);
            LayoutInflater inflater = getLayoutInflater();
            View convertView = null;
            alertDialog.setView(convertView);
            alertDialog.setTitle("All clear");
            alertDialog.show();             

        }


        break;
如果另一个应用程序是recordind,我不会得到消息“你正在被录制!!!” 有什么改进的办法吗