Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Call recording

OP Unknown181

18th July 2014, 12:21 PM   |  #1  
OP Junior Member
Thanks Meter: 0
 
1 posts
Join Date:Joined: Jul 2014
I am currently having trouble with call recording. The problem is with the AudioSouce because when i put MIC it works. Witch AudioSource option REALLY records calls.

Code:

Code:
if (i == REC) {
			try {
				if (isCall == false) {
					Toast.makeText(context, "Not in a call", Toast.LENGTH_SHORT)
							.show();
					return;
				}
				if (IsRec == true) {
					Toast.makeText(context, "Already recording",
							Toast.LENGTH_SHORT).show();
					return;
				}
				o = new File(Environment.getExternalStorageDirectory(),
						"/recordings/"
								+ new SimpleDateFormat("dd.MM.yyyy hh-mm-ss")
										.format(new Date()) + ".amr");
				r = new MediaRecorder();
				r.setOutputFile(o.getAbsolutePath());
				r.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); // HERE
				r.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
				r.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
				try {
					r.prepare();
					r.start();
					IsRec = true;
					Toast.makeText(context,
							"Saving to: " + o.getAbsolutePath(),
							Toast.LENGTH_LONG).show();
				} catch (IllegalStateException e) {
					o = null;
					r = null;
					IsRec = false;
					Log.e("Error", e.getMessage(), e.getCause());
					Toast.makeText(context, "StateE: " + e.getMessage(),
							Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					o = null;
					r = null;
					IsRec = false;
					Log.e("Error", e.getMessage(), e.getCause());
					Toast.makeText(context, "IOE" + e.getMessage(),
							Toast.LENGTH_LONG).show();
				}
			} catch (Exception e) {
				o = null;
				r = null;
				IsRec = false;
				e.printStackTrace();
				Log.e("Error", e.getLocalizedMessage(), e.getCause());
				Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG)
						.show();
			}
		}
LogCat:
Code:
07-18 10:17:18.850: E/MediaRecorder(607): start failed: -2147483648
07-18 10:17:18.859: W/System.err(607): java.lang.RuntimeException: start failed.
07-18 10:17:18.870: W/System.err(607): 	at android.media.MediaRecorder.start(Native Method)
07-18 10:17:18.880: W/System.err(607): 	at com.android.recorder.Widget.onReceive(Widget.java:137)
07-18 10:17:18.890: W/System.err(607): 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2229)
07-18 10:17:18.890: W/System.err(607): 	at android.app.ActivityThread.access$1500(ActivityThread.java:130)
07-18 10:17:18.900: W/System.err(607): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
07-18 10:17:18.919: W/System.err(607): 	at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 10:17:18.919: W/System.err(607): 	at android.os.Looper.loop(Looper.java:137)
07-18 10:17:18.940: W/System.err(607): 	at android.app.ActivityThread.main(ActivityThread.java:4745)
07-18 10:17:18.950: W/System.err(607): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-18 10:17:18.960: W/System.err(607): 	at java.lang.reflect.Method.invoke(Method.java:511)
07-18 10:17:18.969: W/System.err(607): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-18 10:17:18.980: W/System.err(607): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-18 10:17:18.990: W/System.err(607): 	at dalvik.system.NativeStart.main(Native Method)
07-18 10:17:18.999: E/Error(607): start failed.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes