4

enter image description here呼叫記錄問題,並不支持Android 7.0?

問題是通話記錄是工作的罰款高達Android版本6.0.1但不高於Android版本正常工作。

問題: -電話打開1分鐘,但記錄停止2到3秒鐘。

這裏EDITTEXT聯繫人:

edt_attempt_contact.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      final int DRAWABLE_RIGHT = 2; 

      if (event.getAction() == MotionEvent.ACTION_UP) { 
       if (event.getX() >= (edt_attempt_contact.getRight() - edt_attempt_contact.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { 
        if (!edt_attempt_contact.getText().toString().isEmpty()) { 

         Intent i = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + edt_attempt_contact.getText().toString())); 
         try { 
          startActivity(i); 
         }catch (SecurityException s){ 
          s.printStackTrace(); 
         } 

         try { 
          audioRecord(); 
         } catch (IOException e) { 
          e.printStackTrace(); 
         } 
        } else { 
         Toast.makeText(MainActivity.this, "Attempt Contact Number is required to call", Toast.LENGTH_SHORT).show(); 
        } 

        return true; 
       } 
      } 
      return false; 
     } 
    }); 
} 

這裏是電話錄音主代碼。

private void audioRecord() throws IOException { 

    MediaRecorder recorder = new MediaRecorder(); 

    recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
    recorder.setOutputFile(root + "/" 
      .concat("_") 
      .concat(generateUniqueFileName()) 
      .concat(".amr")); 


    try { 
     recorder.prepare(); 
    } catch (IllegalStateException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    recorder.start(); 
} 

我已採取一切需要的Android記錄仍是不提前爲解決以上的Android 6.0.1 versions.Thank你工作在權限...

+0

請添加一個比_「不能正常工作」_更詳細的問題描述。 – Michael

+0

通話開啓1分鐘,但錄音在幾秒內立即停止,即3秒以上的版本... –

+0

是在6.0.1以上版本的代碼中添加的內容?? @Michael –

回答

0

您使用的是電話錄音代碼在服務還是活動?

一旦通話記錄開始,該活動就會停止,因此如果您的代碼處於活動狀態,則通話記錄將停止。

+0

yaa通話錄音處於活動狀態,爲什麼錄音在棒棒糖版本中運行良好? –