B4A Library [B4A] [B4XPages] ScreenRecorder/ScreenShots

B4A B4XPages ScreenRecorder - version 0.7 (25/09/2016)

25/01/2021 - Updated the sample app to use SDK29, foreground services, and also wrote it as a B4XPages app. There are no changes to the library.

Here is a wrapper/library which lets you record the screen and save it as a video file.

It is using MediaProjection which is available from API 21 (Lollipop) and will not work on earlier versions of Android.

It is based on this Github-project. Kudos to the original author.

See next post for events and methods.

I am attaching a sample project along with the library.

Edit: The free version posted here is OK for screen-recording. There is also a more advanced version of this library which enables screen-recording with audio, capturing screenshots and screen-mirroring. Send me a PM (start a conversation) if you are interested.

Some basic stuff to remember:
1) you need at least Lollipop to get this to work. The library uses MediaProjection which was introduced with SDK 21.
2) You cannot use it for a spy-app. When users run your app and the code in your app which triggers the screen-capturing (recording or screenshots), users have to give permission.
3) some apps, such as Telegram, can block MediaProjection, and thus capturing/recording of the screen is not possible.

Please remember that creating libraries and maintaining them takes time and so does supporting them. Please consider a donation if you use my free libraries as this will surely help to keep me motivated. Thank you!


  • B4AScreenRecorderLibs.zip
    7.9 KB · Views: 1,088
  • B4XPagesScreenRecorder.zip
    12.5 KB · Views: 384
Last edited:


Licensed User
B4A ScreenRecorder - version 0.7 (25/09/2016)

moster67/Mikael Osterhed
Version: 0.7
  • ScreenRecorder
    • Result (Grant As Boolean)
    • GetPermission
      Call GetPermission() to let user grant permission.
      Check the Result-event if the user granted the app permission to record
      or not. If the Grant-value is true, permission was granted.
    • Initialize (EventName As String)
      Initializes B4A ScreenRecorder. Make sure to add an EventName since
      it is needed for the GetPermission method.
      Usage of Wrapper:
      Call GetPermission() and then check the Result-event if the user
      granted the app permission to record or not. If the Grant-value is true,
      permission was granted and you can call StartRecording to begin recording.
      To stop recording call StopRecording. Recordings are encapsulated in
      the mp4 container format and can become very large. You should save
      the video on the SD-card.
    • IsInitialized As Boolean
    • StartRecording (width As Int, height As Int, dirPath As String, fileName As String)
      Call StartRecording() to begin recording. You can set video size using
      Width and Height and you can set your own values. However, the real screen sizes
      are suggested (use B4A method GetDeviceLayoutValues). Finally, you need to pass on
      the directory where you want to save the video (sd-card is highly recommended due to size)
      and the file-name. The wrapper does not verify if the file is already existing or not
      and you need to do that yourself.
      Note: Recordings are encapsulated in the mp4 container format and the Wrapper adds
      automatically the mp4-extension to the fileName-parameter.
      Example usage:
      rec.StartRecording(GetDeviceLayoutValues.Width, GetDeviceLayoutValues.Height, File.DirRootExternal, "rec1")
    • StopRecording
      Call StopRecording() to stop recording.



Licensed User
thank for your lib, but can it record audio when record screen??
Currently it does not support audio but I will be working on an enhanced wrapper which hopefully will permit recording of audio too and taking single screenshots...


Active Member
Licensed User
I do appreciate for your effort! Will you accept donation via BitCoin besides PayPal? I want to donate you!


Licensed User
Hi Moster! By any chance have you been able to make any progress on your library? I'm looking very much forward to it!

Thanks for all of your hard work!


Active Member
Licensed User
Dear Moster!
I already tested this lib, and it works like a charm!

Can you improve this lib to be able to record audio and take single screenshot? I think many people here are waiting for you including me :D


Licensed User
Hi Moster, I was wondering if there was any update on your library? I'm pretty close to finishing my app and all that it's missing is your ability to take screenshots, or rather what I really need is just the screen in a bmp object.



Licensed User
Yes, it is already finished (actually been so for quite some time). I am using it in an app I am developing and I will make it available once I have published the app. Just some more patience - it should be a matter of only a few days, maybe even earlier. Sorry for the delay.