0
我是一個新手在android和我工作在一個應用程序,它啓動時,在設備中收到一個phonecall,並啓動一個IntenService記錄呼叫使用媒體記錄器。日誌貓輸出。什麼是錯誤-1在媒體記錄器
01-14 13:58:07.319: D/DEBUG(18180): <!>com.agicent.callrecorder.CallListener 26<!>
OFFHOOK
01-14 13:58:07.319: E/AudioRecordTest(18180):
<!>com.agicent.callrecorder.PhoneCallRecorderActivity 181<!> Recording Started
01-14 13:58:07.469: E/AudioRecordTest(18180):
<!>com.agicent.callrecorder.PhoneCallRecorderActivity 181<!> Recording Started
01-14 13:58:07.499: E/MediaRecorder(18180): start failed: -1
01-14 13:58:07.509: W/dalvikvm(18180): threadid=9: thread exiting with uncaught
exception (group=0x40018560)
01-14 13:58:07.509: E/AndroidRuntime(18180): FATAL EXCEPTION:
IntentService[PhoneCallRecorderActivity]
01-14 13:58:07.509: E/AndroidRuntime(18180): java.lang.RuntimeException: start failed.
01-14 13:58:07.509: E/AndroidRuntime(18180): at
android.media.MediaRecorder.start(Native Method)
01-14 13:58:07.509: E/AndroidRuntime(18180): atcom.agicent.callrecorder.PhoneCallRecorderActivity.startRecording(PhoneCallRecorderActivity.java:77)
01-14 13:58:07.509: E/AndroidRuntime(18180): at com.agicent.callrecorder.PhoneCallRecorderActivity.onHandleIntent(PhoneCallRecorderActivity.java:182)
01-14 13:58:07.509: E/AndroidRuntime(18180): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
01-14 13:58:07.509: E/AndroidRuntime(18180): at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 13:58:07.509: E/AndroidRuntime(18180): at android.os.Looper.loop(Looper.java:123)
01-14 13:58:07.509: E/AndroidRuntime(18180): at android.os.HandlerThread.run(HandlerThread.java:60)
01-14 13:58:20.539: E/IncomingCall Recieved(18256): <!>com.agicent.callrecorder.IncomingCallReciever 33<!> Broadcast Recieved
01-14 13:58:20.569: D/DEBUG(18256): <!>com.agicent.callrecorder.CallListener 22<!> IDLE
這裏我我的代碼塊
public class PhoneCallRecorderActivity extends IntentService {
private static final String LOG_TAG = "AudioRecordTest";
private static String mFileName = null;
//private RecordButton mRecordButton = null;
private MediaRecorder mRecorder = null;
//private PlayButton mPlayButton = null;
private MediaPlayer mPlayer = null;
private void startPlaying() {
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(mFileName);
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
private void stopPlaying() {
mPlayer.release();
mPlayer = null;
}
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
public PhoneCallRecorderActivity() {
super("PhoneCallRecorderActivity");
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/audiorecordtest.3gp";
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
Log.e(LOG_TAG, "Recording Started");
startRecording();
}
public void onDestroy() {
stopRecording();
Log.e(LOG_TAG, "Recording finidhed");
}
}
請建議我在哪裏,我做錯了。 非常感謝您的時間。
也發佈您的清單權限。 – 2012-01-14 11:35:05
http://stackoverflow.com/questions/5630922/how-to-record-a-call-in-android – 2012-01-16 07:40:56