Skip to content Skip to sidebar Skip to footer

Startrecording() Called On An Uninitialized Audiorecord

i am trying to record voice call on android. I am using AudioRecord class/api of android to perform this. But for some reason AudioRecord is not able to record voice call on some d

Solution 1:

You need to explicitly ask for:

<uses-permissionandroid:name="android.permission.RECORD_AUDIO"/>

on all devices after Lollipop so API lvl 23+

if (ContextCompat.checkSelfPermission(thisActivity, 
    Manifest.permission.RECORD_AUDIO)
        != PackageManager.PERMISSION_GRANTED) {
    ActivityCompat.requestPermissions(thisActivity,
            newString[]{Manifest.permission.RECORD_AUDIO},
            1234);
}

and then override:

@OverridepublicvoidonRequestPermissionsResult(int requestCode,
        String permissions[], int[] grantResults) {
    switch (requestCode) {
        case1234: {
            // If request is cancelled, the result arrays are empty.if (grantResults.length > 0
                && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                initializePlayerAndStartRecording();

            } else {
                Log.d("TAG", "permission denied by user");
            }
            return;
        }
    }
}

Post a Comment for "Startrecording() Called On An Uninitialized Audiorecord"