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 to periodicaly record screen from a background service using Android API MediaProjection?

Hello I'm building a weak AI (a bot) app on android but I'm fairly new to this. Context: The app is/will be composed of an UI to start/stop the bot and modify his settings, screen caputure service taking screenshot at fixed intervals (let's say…
2
votes
0 answers

ActivityNotFoundException unable to find explicit activity class MediaProjectionPermissionActivity

I have strange problem with MediaProjectionManager. Because general it works but on some device like HUAWEI Y560 i get this error: android.content.ActivityNotFoundException: Unable to find explicit activity class…
Michael
  • 780
  • 1
  • 10
  • 34
2
votes
1 answer

Android VirtualDisplay.release() not releasing the display

I'm using android MediaProjection for taking screenshot. The projection needs to be stopped after taking screenshot and virtual display should be released but VirtualDisplay.release() is not releasing the display. Here is the code to create…
Abbas Ali
  • 41
  • 4
2
votes
2 answers

How to use the MediaProjection API, from Android, to record system audio that is outputted in an android device?

Please, I liked to know how to use the MediaProjection API, from Android, to record system sound that is outputted in an android device? The system sound, that I want to record, is outputted from some user app, in speakers, or in headsets, from an…
2
votes
1 answer

What would be the most efficient way to buffer the last X minutes of MediaProjection

I'm having a bit of trouble thinking of an efficient solution. There are a few problems I am foreseeing, the first being... OOM Prevention If I wanted the past 30 seconds or even 5 minutes it's doable, but what if I wanted the past 30 minutes or…
2
votes
0 answers

Is it possible to capture secure Android app if launched from own activity?

I am looking for a way to share my apps screen content through a secure channel with a server. Using the new MediaProjection library seems to bee a perfect solution. The problem is, that the app / its views have to be marked as secure. Is there…
david
  • 662
  • 5
  • 8
2
votes
1 answer

Adding microphone input to MediaMuxer Android

Hey I'm trying to develop screencast app which would record the contents of the screen as well as microphone input. I was able to implement the video recording but I can't find anything about adding microphone input to mediaMuxer. I know I could use…
2
votes
1 answer

How can I use media projection for older api?

I want to record the screen contents for 1 min. After searching google, I found that the api level 21 contains MediaProjecion class. My app is build for api level 18. Can I use this class? Is there any support library for this?
Numa Fitness
  • 73
  • 1
  • 7
2
votes
0 answers

Bitmap from ImageReader always blank when trying to capture screen

Using the MediaProjection API for screen capture, I create an ImageReader and feed use it as a point of access for captured screens as below: mImageReader = ImageReader.newInstance(mWidth, mHeight, ImageFormat.JPEG, 2); and…
2
votes
1 answer

Android - Get byte[] from Surface / virtualDisplay

I am trying to screen cast my android device screen to a web browser using projection API and Webrtc. Projection API renders its output to a Surface and returns a virtualDisplay. I have done till this. I saw the webrtc library for android. they have…
shubendrak
  • 2,038
  • 4
  • 27
  • 56
2
votes
1 answer

How to capture a screenshot programmatically with Lollipop

The Media Projection package is new Lollipop, and allows an app to capture the device's screen in realtime for streaming to video. I was hoping this could also be used to capture a single still screenshot, but so far I have not been successful. Of…
pents90
  • 1,782
  • 17
  • 17
2
votes
1 answer

Android MediaProjection API callback when the user cancels projection from notification bar

I am currently using Android 5.0 MediaProjection API. I have successfully been able to start a projection session from my application, however I have noticed that the user can at any point in time go to the notification bar and stop media…
mtsahakis
  • 793
  • 1
  • 8
  • 18
1
vote
0 answers

How take a Screenshot in Floating Window Mode with MediaProjection API?

I'm trying to take a screenshot after I minimize my App and enter Floating Window Mode (like Facebook Messenger) so when I click on the minimized icon, I can take a screenshot. I found some relevant samples on screen capture:…
1
vote
0 answers

How to access granted media_projection thought root?

how can I use the root command to grant permission to "media projection" or to another: "screen capture/screenshot"? maybe it's some kind of "activity" you need to run? I tried to grant permissions, the root commands didn't help. Maybe I just…
007wan
  • 11
  • 2
1
vote
1 answer

How AirDroid Business is able to exclude overlay from screenshot?

Someone know how they achieved it? They using MediaProjection apis to capture device screen, but one people here on SO said that these apis not offer this feature (exclude overlay). Then how they achieved this success?
FLASHCODER
  • 1
  • 7
  • 24