How to check if an Android device has voice capabilities

后端 未结 4 1976
孤街浪徒
孤街浪徒 2021-02-06 15:11

Does anyone know a good way of programmaticaly checking if an Android device, phone or tablet, has voice capabilities? By voice capabilities I mean capability to make phone call

4条回答
  •  执笔经年
    2021-02-06 15:55

    I would assume that prepare() would fail if there is not mic available:

      mRecorder = new MediaRecorder();
      mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      mRecorder.setOutputFile(audio_file);
      mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
      try {
          mRecorder.prepare();
          mRecorder.start();
      } catch (Exception e) {}
    

提交回复
热议问题