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
1
vote
0 answers

In Android how can I take multiple images using ImageReader class

I am trying to take multiple images but the ImageAvailabeListener function is not moving forward. I guess it is waiting for next image. I tried aquireNextImage() but it is also not working. I'm taking images while MediaProjection. class…
1
vote
1 answer

Android 13 media projection screenshot is black

I am having an error with the media projection and taking screenshots but only with android 13, sometimes they come out black, but not always. I have tried to put a delay (up to 5 seconds) to see if maybe the android system was the cause of it, but…
Jayce
  • 781
  • 3
  • 16
  • 35
1
vote
0 answers

Android get real time screen display stream

I am working on a project that requires me to stream screen between two android devices over wifi-direct. so is it possible to just grab android screen stream and then perform processing/sharing with it.
1
vote
0 answers

Image Reader Works on Virtual Device, Not on Real Device

Image Reader Not Working on Real Device In Media Projection, when trying to capture the screen with the createVirtualDisplay function, ImageReader is running in Virtual Device and it always captures different images, but after capturing several…
1
vote
1 answer

Android - Reading VirtualDisplay frames in real time

I am capturing my Android device's screen using the MediaProjection API by creating a VirtualDisplay and displaying it on a SurfaceView that remains always visible. I would like to perform some image processing on the frames grabbed by the…
1
vote
1 answer

Defining an area for a screen capture on android

I currently have a VirtualDisplay set up using the MediaProjection API which is being drawn on to a SurfaceView that is always visible. The VirtualDisplay is, however, capturing the entire display but I would like it do capture only the portion of…
1
vote
0 answers

Taking single screenshot instead of whole video

I am using the MediaProjection API to record a short video of whatever is happening on screen, save the video to file, and then I retrieve screenshots by iterating on the frames. Instead of doing this, is it possible to take directly a screenshot? I…
1
vote
0 answers

How to slice AVC/H.264 frames on android?

My network MTU is limited to only 0xFFFF bytes. That is mostly OK with 800 x 480 resolution but sometimes exceeds, causing lost of frames. I managed to lower the NAL max size by lowering resolution and bitrate but that greatly reduced image…
1
vote
0 answers

Media Projection resets ARCore session

I am working on an Ionic project where I am using ARCore via a custom plug-in. In the webview I am rendering the 3D object and receiving ARCore pose info from native android per frame. Now I have a requirement to capture the ARCore session along…
Raki
  • 329
  • 3
  • 18
1
vote
0 answers

Is it possible to do screen recording without using foreground service for Android app targeting API 29?

The following code works fine for devices lower than Android 10 startActivityForResult(mProjectionManager.createScreenCaptureIntent(), REQUEST_CODE_SCREEN_RECORDING); ... MediaProjectionCallback mMediaProjectionCallback = new…
Hong
  • 17,643
  • 21
  • 81
  • 142
1
vote
2 answers

Android 10: android:foregroundServiceType="mediaProjection" not working with service

Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION I am trying to capture the screen using MediaProjection API but my app is continuously crashing. I tried and giving this error: …
1
vote
1 answer

Is it possible to use MediaProjection API and process every recorded frame during recording?

I want to build an app which simulates ambilight you know from Philips TV's. For this I have an Arduino that controls my LEDs and listens for commands on the serial port to set the color of the LEDs. In theory I want my app to record the screen of…
1
vote
1 answer

Problem with the Bitmap to take screenshots

I have this line of code for taking screenshots I take the screenshot but somethimes the image only show a white backgroud and doesn't show the full color of the image how can I solve this? Postdata I have other question with the fullcode Problem…
1
vote
0 answers

other ways of capturing screenshot from device

I am using android media projection but it does not meet my needs. Since it does not have "don't ask me again" check box on android Q. is there any other way to capture screenshot on android except using media projection?
Ee Pa
  • 11
  • 1
1
vote
1 answer

How to lock android screen during screen mirroring?

I am developing an android application for mirroring android screen to car display. I used MediaProjection for getting screen; using that api I was able to mirror screen and now I want to lock android screen during mirroring to avoid distraction of…