Questions tagged [android-mediaprojection]

MediaProjection is an Android class that facilitates capturing the screen and recording system audio.

The android.media.projection classes were introduced in Android API 21 to allow applications to record still images, video, and (potentially) audio from the device. In previous releases, applications were only allowed to capture their own rendering, and different approaches were required for View-based UI and OpenGL ES rendering.

Because capturing content outside of the current application has security implications, applications wishing to use these features must get permission from the user first. This is handled through the MediaProjectionManager.

An official screen capture example can be found on github.

The images captured by the MediaProjection are sent to a virtual display, which takes a Surface as an argument. The Surface can be provided by a SurfaceView (for immediate display), an ImageReader (for access from software), constructed from a SurfaceTexture (for use as an OpenGL ES texture), or by MediaCodec/MediaRecorder (for video encoding).

178 questions
2
votes
0 answers

How can I draw a view which is excluded from media projection?

I want to draw a view and exclude it from media projection. I found some apps already have this behavior, so I think it is possible. For example, when I share screen of android mobile phone to Samsung TV, floating button and control pannel is only…
Gimun Eom
  • 411
  • 5
  • 17
2
votes
0 answers

Cannot start already started MediaProjection and rarely NullPointerException when invoking MediaProjection.createVirtualDisplay

These are the errors I am getting: 2021-10-31 12:18:44.281 15783-15921/com.exabes.test E/AndroidRuntime: FATAL EXCEPTION: Thread-7 Process: com.exabes.test, PID: 15783 java.lang.IllegalStateException: Cannot start already started…
DeborahAnn
  • 191
  • 1
  • 11
2
votes
1 answer

call release() did not work after creating virtual display

I used MediaProjection to create VirtualDisplay to take screenshots. Afterward, I tried to release the virtualDisplay, but it did not work: // create virtual display... mVirtualDisplay = sMediaProjection.createVirtualDisplay(DISPLAY, mWidth,…
2
votes
1 answer

Doing a task after a view became invisible

I'm writing a screenshot app using Android MediaProjection Api in which an overlay button is shown on top of everything and user can click it to capture a screenshot anywhere. Since MediaProjection records screen content, overlay button itself is in…
2
votes
1 answer

How to take a Screenshot from a background-service class using MediaProjection API?

After doing a lot of research on this topic, though I found a few answers, I could not understand how the MediaProjection API works. I want to take a screenshot of the device from a background Service class. Is it possible to do it. I have one…
2
votes
1 answer

How to prevent ActivityManager from killing my application's background process

I am developing a mobile application that runs in the background. It takes screenshots in the background on an interval, however after some time, ActivityManager would kill the process with the log, I/ActivityManager: killing com.example: excessive…
2
votes
0 answers

convert image class from RGBX_8888 to RGBA_8888 or get rgb value from RGBX_8888

I develop the app that take screenshot of other apps. when I develop it using android device the code below works. mImageReader = ImageReader.newInstance(mWidth, mHeight, PixelFormat.RGBA_8888, 5); but the code doesn't work in android app…
2
votes
0 answers

How to take screenshot from surfaceView in VLC

I am playing streaming in vlc player and using surfaceView to show streaming, Now, i want to take screenshot of streaming at any time. Problem Now problem is that we can not take screenshot of SurfaceView. I also saw a sample of Media Projection but…
2
votes
1 answer

extra padding while taking screenshot using MediaProjection API

I am using the following code to obtain a screenshot. I get the screenshot but there is black padding attached to the image. The code samples found on the internet to take screenshot and to remove padding are used here: // requesting permission …
Usman
  • 2,331
  • 2
  • 21
  • 29
2
votes
1 answer

How can i remove small notification when use Media Projection for screen recording?

Can i remove small notification when use Media Projection for screen recording or screen capture ? Notification Like This
Young King
  • 79
  • 2
  • 13
2
votes
1 answer

permission of start capturing everything that display in my screen in android

I can capture everything on my screen using android MediaProjection api along with MediaRecorder API. When i try to capture for the first time it prompt for permission automatically. I want to take permission manually for Marshmallow. How can i take…
2
votes
0 answers

Android : start screen capture without creating new activity

I am trying to record screen video using MediaProjection. I want to capture video in the same activity and not start another activity. I have gone through a few tutorials. In these tutorials, a call is made to startActivityForResult with…
ashwin mahajan
  • 1,654
  • 5
  • 27
  • 50
2
votes
1 answer

Transmit output of MediaProjection API over network

I've been reading on MediaProjection API, and checked out a few sample projects on Github that show how to use it. All those projects only show how to save the screen capture in a file ( record the screen ), and nothing about transmiting it in…
Rick Sanchez
  • 4,528
  • 2
  • 27
  • 53
2
votes
1 answer

Taking capture by using MediaProjection API for emulator generates black screen

I’m trying to capture emulator screen by using MediaProjection API and ImageReader. But it always generates black screen. The code is as follows. @Override public void onImageAvailable(ImageReader reader) { Log.i(TAG, "in OnImageAvailable"); …
2
votes
0 answers

Android MediaProjection can record objects(only activity)?

From the lollipop version MediaProjection API was released and it became much easier to take a screenshot or record a screen. BUT I would like to record the screen which I want to. It's more like "object recording" not the whole screen. For…