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
4
votes
1 answer

createScreenCaptureIntent doesn't return result

I'm trying to deal with the new Android Lollipop MediaProjection API. I have found that (at least on my stock Samsung Galaxy S4 jfltexx) when I start the intent to get permission to capture the screen (ProjectionManager.createScreenCaptureIntent()),…
3
votes
2 answers

Take a screenshot from a service using MediaProjection

I'm trying to take a screenshot from a service using MediaProjection. Despite defining the type of my service as mediaprojection in AndroidManifest.xml and running mediaProjection in a service I get the following error: FATAL EXCEPTION:…
3
votes
0 answers

how to take a screenshot through a floating widget in any activity in android

I know there is same question on SO and I also know that question has one answer with two downvotes. Here is what I'm doing to take a screenshot private Bitmap takeScreenshot(){ View rootView =…
Tehleel Mir
  • 743
  • 8
  • 27
3
votes
0 answers

Android MediaProjection. acquireLatestImage always return Null for ImageReader

I am writing simplee Screenshot App and use MediaProjection + ImageReader for this. I use some sample for resolve this task. When i click on Capture button, i ALWAYS get "image: NULL" in the log message. In ImageReader.newInstance i set Format as…
Tomas
  • 1,567
  • 3
  • 21
  • 38
3
votes
0 answers

How to display other app in surface view?

I would like to mirror e.g. Waze in my app SurfaceView: Intent intent = getPackageManager().getLaunchIntentForPackage("com.waze"); //"com.waze" Bundle opts = ActivityOptions .makeBasic() …
3
votes
0 answers

Android screen recorder with internal audio

I'm trying to record the android mobile screen using Mediaprojection and Media Recorder. I'm able to record the screen along with audio using mic. Below is my code. private void initRecorder() { try { File backupPath =…
3
votes
1 answer

Video captured from Android screen recorder can not be played on web browser

I encounter a problem when I try to play a video on a web browser in a component, the file can not play at all. The file was captured on Android device using MediaRecorder and MediaProjection and tried to record screen. Here is the code how I…
3
votes
2 answers

Taking a screenshot of a composite screen view of a regular View and SurfaceView

So, I have a Camera Preview (backed by a surface view) and has regular Android UI views laid as overlay over the preview. How do I take a simple screenshot of the displayed screen view. I tried with MediaProjection and could not make it work (I am…
3
votes
1 answer

Screen Recording output get distorted on some Samsung Devices

I'm trying to capture a video of Android devices' screens, but on some Samsung devices, I got the video masked with a pink distortion overlay. Check the below screenshot of output videos on Samsung DOUS and Pixel XL: - Samsung DUOS G532F(API 23) -…
Amr Barakat
  • 686
  • 1
  • 7
  • 16
3
votes
0 answers

Stream android screen with MediaProjection API

i would like to build an Android application to stream the screen to a Java desktop program, but i don't understand how to get the video to be sent to pc. The answer at this link suggests to use LocalSocket and LocalServerSocket: but aren't…
acjnyd
  • 31
  • 4
3
votes
0 answers

Error when recording audio using MediaProjection api on android 5.0

case 1: I am working on VOIP project where users can talk using their android smartphones. case 2: The same time i also want to record the voice & video on a device and save it on local sd card. The problem is i am not able to record voice in case…
3
votes
0 answers

VirtualDisplay.Callback onPause Not Called

I'm trying to deal with some timing issues I've seen with a VirtualDisplay as mentioned here and I decided to use a VirtualDisplay.Callback to see if it would potentially fix my timing issues. Only problem is that my callback never receives onPause…
EncodedNybble
  • 265
  • 2
  • 11
3
votes
0 answers

Android virtual display release does not remove display

I am using android Virtual Display along with Projection Manager At certain time, the projection need to be stopped, hence the following actions are taken @Override public void surfaceDestroyed(SurfaceHolder holder) { …
nmxprime
  • 1,506
  • 3
  • 25
  • 52
2
votes
0 answers

Android Media Projection Screen Capture Works Differently On Real Device

When I Run The Code Below, Continuous Screen Recording Is Working In The Virtual Device And Capturing The Pictures. However, when the code is run on the real device, they are all the same, except for a few of the captured images (with the exception…
2
votes
0 answers

Any cordova plugin for screen sharing or support for getDisplayMedia?

Is there any plugin or code that support screen sharing on Android using cordova? Have been searching everywhere but in vain. Kind of understood we need to use Media Projection but couldn't find a good way to get the video track from the Media…
1 2
3
11 12