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

How to properly take a screenshot, globally?

Background Since Android API 21, it's possible for apps to take screenshots globally and record the screen. The problem I've made a sample code out of all I've found on the Internet, but it has a few issues: It's quite slow. Maybe it's possible to…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
16
votes
7 answers

Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE TYPE_MEDIA_PROJECTION in Android Pie and Q

any body knows why this error occur, Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION on getMediaProjection() even i call getMediaProjection() method after calling startforeground()…
14
votes
1 answer

Stream android screen

I am trying to fallow Truiton ScreenCapture example, in order to record the device screen using MediaProjection When saving the recording localy it works mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE); …
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
12
votes
2 answers

MediaProjection service type not recognized in android Q

With the new privacy changes in effect with Android Q, it is now mandatory for any app using MediaProjection api to specify android:foregroundServiceType attribute in the service tag under manifest. But recently, I noticed that though I set the…
Vijai
  • 1,067
  • 2
  • 11
  • 25
11
votes
3 answers

android mediaprojection screenshot contains black frame

I am working on recording my screen with MediaProjection as follows Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); displayWidth = size.x; displayHeight = size.y; imageReader =…
AMD
  • 1,662
  • 18
  • 39
10
votes
3 answers

Android MediaProjectionManager in Service

I want to build an app where I have to use MediaProjectionManager in a Service. But I can not solve it as 'startActivityForResult' can't use in Service class.
9
votes
1 answer

how to take MediaProjectionManager screen caputuring permission for only once instead of each time use?

public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; private static final int REQUEST_CODE = 1234; private int mScreenDensity; private MediaProjectionManager mProjectionManager; private static…
Md. Sulayman
  • 781
  • 8
  • 30
8
votes
1 answer

Mediaprojection issues on Android 9+

I made an OCR application that makes a screenshot using Android mediaprojection and processes the text in this image. This is working fine, except on Android 9+. When mediaprojeciton is starting there is always a window popping up warning about…
8
votes
0 answers

Making a FLAG_SECURE window invisible from a screenshot on Android

I have a floating window that has a flag FLAG_SECURE. It is successfully hidden from screencaptures and a MediaProjection that I have set up. It is shown as black rectangular object when I record through a MediaProjection. Everything from my…
Marlon
  • 1,839
  • 2
  • 19
  • 42
8
votes
1 answer

Android ImageReader get NV21 format?

I do not have a background in imaging or graphics, so please bear with me :) I am using JavaCV in one of my projects. In the examples, a Frame is constructed which has a buffer of a certain size. When using the public void onPreviewFrame(byte[]…
Gooey
  • 4,740
  • 10
  • 42
  • 76
8
votes
3 answers

How to use Mediaprojection library in android to capture screen and convert into mp4 file?

Since android 5.0 they are providing mediaprojection library to capture screen content. but sample demo application provided by them is not clear. U can find sample app here. In that application they are projecting captured screen using…
7
votes
2 answers

Hide a secure view completely in MediaProjection - android

I'm creating a screen recorder app using the MediaProjection API. In my app, I'm showing the stop button as a small overlay window. I've kept this view as secure so that it doesn't come up in the final recorded video. This view doesn't come up in…
6
votes
1 answer

Screen Sharing between Devices using Media Projection API

I am developing an app which has the functionality of sharing screens with other apps. I used the Media projection API for this. I also used MediaMuxer to combine the audio and video outputs for screen sharing. I know that Media Projection APIs are…
6
votes
0 answers

Android MediaProjection screen mirroring to Web browser over USB

I want to mirror Android Screen to desktop web browser. I am able to capture the screen using MediaProjection - thanks to sample app. But next part is hard one - sending captured data to desktop! I know the technique to establish HTTP connection to…
iuq
  • 1,487
  • 1
  • 20
  • 42
6
votes
1 answer

Screen capture with background service

I started to work with Lollipop & Media.Projection class to implement a screen sharing app. The demo project from Google is quite good enough for me to understand this new feature of Lollipop. But then I found it's hard to make the screen capture…
1
2 3
11 12