I try to organize background video recording in Android 4.0. But I can't do it because of these problems:
Dummy Surface does not work in MediaRecorder (error: invalid surface)
If you use Surface 1 x 1 px on Activity, Surface is destroyed on Activity pause (recording is stopped)
If you use Surface 1 x 1 px on WindowsManager, Surface is destroyed on Application pause (recording is stopped)
SurfaceTexture does not work in MediaRecorder.setPreviewDisplay(new Surface(SurfaceTexture))
Widget does not allow to handle Surface 1 x 1 px
Status Bar does not allow to handle Surface 1 x 1 px
Please, help me to find right way.
Just a small modification to the above code...it will save the 5sec file to the root folder in ur sdcard...modify the timer according to ur need. and it worked on Nexus 4 and Micromax as well..
Sample and simple code (tested on Jelly Bean, SGS2):
Don't forget about permissions:
I found the answer: it is necessary to use WindowManager and call it from Service.