MediaRecorder: start failed
recorder.prepare();
Thread.sleep(1000);
recorder.start();
For incoming call it was taking time to prepare.
Hold the prepare for 1 sec and everything is worked fine.
E/MediaRecorder: start failed: -38
Updated
While working on this, I found out that I was testing my project on android Lolipop and it is not possible to read and write directly on LocalSockets. You have to use ParcelFileDiscriptor to stream audio.
MediaRecorder Android 11 start failed -1004
Replace "/dev/null" with the correct file path "${externalCacheDir.absolutePath}/test.3gp" and it should work.
MediaRecorder Start Failed Error
code 2147483648
refers to MEDIA_ERROR_SYSTEM (low-level system error).
Based on the documentation:
A BroadcastReceiver object is only valid for the duration of the call
to onReceive(Context, Intent). Once your code returns from this
function, the system considers the object to be finished and no longer
active.
In other words, the MediaRecorder instance that you expect to be there might actually not exist anymore since you're within a different BroadcastReceiver instance than the one that created the MediaRecorder. Its not a great idea to perform this task in BroadcastReceiver since it will only execute for 10 seconds after which System could declare app as not responding.
One solution would be to execute this code to Service
Related Topics
Android Studio Build.Gradle Warning Message
Getting Nosuchfielderror Instance Org/Apache/Http/Message/Basicheadervalueparser
Getting Permission Denial Exception
Android Viewpager Implementation
Gradle Sync Failed Could Not Find Constraint-Layout:1.0.0-Alpha2
Firebase Ontokenrefresh() Is Not Called
Android: Setselection Having No Effect on Spinner
How to Hide Toolbar When I Scrolling Content Up
What Is a Maximum Size of SQLite Database on Android
Listen to Own Application Uninstall Event on Android
How to Disable Status Bar Click and Pull Down in Android
Using Camera in the Android Emulator
Run Task Before Compilation Using Android Gradle Plugin
How to Open My Existing Eclipse Projects in Android Studio
Programmatically Add View One Below Other in Relative Layout