block call recording in android

archish picture archish · May 6, 2015 · Viewed 8.6k times · Source

I want to create application in android which will block call recording.if someone has secretly install call recording app in my phone like virus or something then this app will restrict/prevent all call recording.

so my question is

Is there any way to block call recording?

Thank you in advance.

Answer

Narendra Baratam picture Narendra Baratam · Apr 2, 2016

I think its possible!!! If one android device is running with two different call recording apps, the call will recorded by first app only, which will use the call recording resources in that device, rest of all apps will fail to record, because the resources can be used by one app at a time, its a computation, who will trigger to start using resources will gonna win..it can be your app!!

I'm just giving Idea only, not the perfect solution!!!

Sample code(Not Full code):

       MediaRecorder recorder = new MediaRecorder();

 Log.d(TAG, "RecordService will config MediaRecorder with audiosource: " + audiosource + " audioformat: " + audioformat);
    try {
        // These calls will throw exceptions unless you set the
        // android.permission.RECORD_AUDIO permission for your app
        recorder.reset();
        recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        Log.d(TAG, "set encoder default");
        recorder.setOutputFile(recording.getAbsolutePath());
        Log.d(TAG, "set file: " + recording.getAbsolutePath());
        //recorder.setMaxDuration(msDuration); //1000); // 1 seconds
        //recorder.setMaxFileSize(bytesMax); //1024*1024); // 1KB

        recorder.setOnInfoListener(this);
        recorder.setOnErrorListener(this);

        try {
            recorder.prepare();
        } catch (java.io.IOException e) {
            Log.e(TAG, "RecordService::onStart() IOException attempting recorder.prepare()\n");
            Toast t = Toast.makeText(getApplicationContext(), "CallRecorder was unable to start recording: " + e, Toast.LENGTH_LONG);
            t.show();
            recorder = null;
            return; //return 0; //START_STICKY;
        }
        Log.d(TAG, "recorder.prepare() returned");

        recorder.start();
        isRecording = true;
        Log.i(TAG, "recorder.start() returned");
        //updateNotification(true);

    } catch (java.lang.Exception e) {
        Toast t = Toast.makeText(getApplicationContext(), "CallRecorder was unable to start recording: " + e, Toast.LENGTH_LONG);
        t.show();

        Log.e(TAG, "RecordService::onStart caught unexpected exception", e);
        recorder = null;
    }