title: How to get dataline to mic and record get samples in android
body: <p>I am trying to get microphone data line on an Android phone and get sound in to a byte buffer using particular sampling period. I coded this in Java using <code>TargetDataLine</code>. But it shows an error when working with Android. So is there some way to do this or can I use this <code>TargetDataline</code> as it is in Android? Thank you!</p>
  
  <pre><code>private void captureAudio(){
      try{
        audioFormat = getAudioFormat();
        DataLine.Info dataLineInfo =new DataLine.Info(TargetDataLine.class,audioFormat);
        targetDataLine = (TargetDataLine)AudioSystem.getLine(dataLineInfo);
        targetDataLine.open(audioFormat);
        targetDataLine.start();
        Thread captureThread =new Thread(new CaptureThread());
        captureThread.start();
        } catch (Exception e) {
        System.out.println(e);
        System.exit(0);
      }//end catch
    }//end captureAudio method
  </code></pre>
  
  <p>*</p>