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,089
  • B4XPagesScreenRecorder.zip
    12.5 KB · Views: 384
Last edited:


Licensed User
I tried to compile your sample project and I got this error :
AndroidManifest.xml:37: error: No resource identifier found for attribute 'foregroundServiceType' in package 'android'

I noticed that you specified
 ************** This wrapper requires at least => SDK/API 21 (lollipop) so don't forget to set this in the manifest. **************
but this is not clear what I should not forget (I tried compiling with several target systems over Lollipop)

My understanding is that your program needs "mediaProjection" library as requested in the manifest
SetServiceAttribute(Screen, android:foregroundServiceType, "mediaProjection")
Could you help to solve this issue ?


Licensed User
and I got this error
What is the path to Android.jar you are using? It should point to [...]\Platform-30\Android.jar

Follow the installation instructions carefully: