2012-02-10 5 views
0

이 때 나는 다른 문제가 있습니다. 녹음 전화에 응용 프로그램이 있지만 recorder.start()는 끝나지 않습니다. A 버튼 숫자를 호출 할 때녹음 전화가 절대로 끝나지 않습니다.

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); 
    recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); 
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
    recorder.setOutputFile(path); 
    recorder.setMaxDuration(1000); 
    recorder.prepare(); 
    recorder.start(); 

이 코드 부분을 실행한다 여기에 기록하기위한 코드이다. 나는 AVD에서 통화 종료 버튼을 누를 때,이 코드는 실행되지 않습니다 :

 phoneListener = new PhoneStateListener() 
     { 
      @Override 
      public void onCallStateChanged(int state, String incomingNumber) 
      { 
       switch (state) 
       { 
        case TelephonyManager.CALL_STATE_IDLE: 
         currentPhoneState = "CALL_STATE_IDLE"; 
        break; 
        case TelephonyManager.CALL_STATE_OFFHOOK: 
         currentPhoneState = "CALL_STATE_OFFHOOK"; 
        break; 
        case TelephonyManager.CALL_STATE_RINGING: 
         currentPhoneState = "CALL_STATE_RINGING"; 
        break; 
       } 

       _fileTrace.onTrace("INFO", "CallState: ", currentPhoneState, null); 
       if (currentPhoneState == "CALL_STATE_OFFHOOK") 
       {      
        llamada = true; 
        _fileTrace.onTrace("INFO", "Recording Start", currentPhoneState, null); 
        try { 
         recorder.start(); 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 
       } 
       if (llamada && currentPhoneState == "CALL_STATE_IDLE") { 
        _fileTrace.onTrace("INFO", "CallState: ", currentPhoneState, null); 
        recorder.stop(); 
       }     
      } 
     };  
     _CurrTelephonyManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE); 

을 참고 : 코드의 첫 번째 조각은 도우미 클래스에 있고 둘째는 활동이다.

누군가가 나를 도울 수 있기를 바랍니다. 감사합니다.

+0

일부 안드로이드 디바이스가 나를 도와? – AuTi

+0

이 게시물에 마지막 기회! – AuTi

답변

1

난 다음을 사용 코드와 그 일 :

public void onReceive(Context context, Intent intent) { 
    // Toast.makeText(context, "calling now", Toast.LENGTH_LONG).show(); 
    if (!intent.getAction().equals("android.intent.action.PHONE_STATE")) 
     return; 
    else { 
     String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); 

     if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { 
      log.d(TAG, "RINGING NOW") 

      return; 
     } else if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) { 
      StartRecording(); 
      Log.d(TAG, "CALL ANSWERED NOW"); 
      return; 
     } else if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) { 
      Log.d(TAG, "ALL DONE IN ELSE IF...... !!"); 
      StopRecording(); 
     } else { 
      Log.d(TAG, "ALL DONE IN ELSE ...... !!"); 

     } 
    } 
} 
관련 문제