Open Fenrisus opened 3 years ago
[BroadcastReceiver]
[IntentFilter(new[] { "android.intent.action.PHONE_STATE" })]
public class IncomingCallReceiver : BroadcastReceiver
{
public TelephonyManager _Manager { get; set; }
public override void OnReceive(Context context, Intent intent)
{
_Manager = context.GetSystemService(Context.TelephonyService) as TelephonyManager;
if (_Manager == null)
return;
_Manager.Listen(listener, PhoneStateListenerFlags.CallState);
//Do something here?
}
}
Also there is the possible way to do similar with VoIP connectionsvia tracking AudioDevice state at service
And do the something like:
public VoiceCallRecorder()
{
_Recorder = new MediaRecorder();
_Recorder.SetAudioSource(AudioSource.VoiceCall);
//API requirements
//Container : WAV
//Encoding : PCM
//Rate : 16K
//Sample Format : 16bit
//Channels : Mono
_Recorder.SetOutputFormat(OutputFormat.Mpeg4);
_Recorder.SetAudioEncoder(AudioEncoder.Aac);
var storage = File.CreateTempFile("data_", ".mp4", Android.OS.Environment.ExternalStorageDirectory);
_OutputPath = storage.AbsolutePath;
_Recorder.SetOutputFile(_OutputPath);
_Recorder.Prepare();
}
public void RecStart()
{
if (IsRec) return;
_Recorder.Start();
IsRec = true;
}
How about to capture VoIP and PhoneCall save it and send to server?