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

Application screen recording in Android

I want to record my own application's window. The only relevant API I see is media projection. I would use it but it requires user consent because it enables screen capturing of other applications. I'm interested only in my own application…
rlib
  • 7,444
  • 3
  • 32
  • 40
0
votes
1 answer

How we can capture entire screen screenshot using android application via programming

Can anyone having idea how we can capture entire screen screenshot including other application overlay menu and toast using android application programming not for adb commands and manual button press. I have went through some of the code which is…
0
votes
0 answers

In Android how can I take multiple images through 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. private class…
0
votes
3 answers

Programmatically take screenshot Android 13

I have the following code, which works perfectly fine on Android 12 and below, but for a weird reason, Android 13 takes "black" screenshots, about 95% of the time. fun setVirtualDisplay() { mImageReader = ImageReader.newInstance( …
0
votes
0 answers

Example of making screenshot using Foreground MediaProjection Button

I try to realize an application which is include a creation of screenshot using Foreground MediaProjection Button OUTSIDE of any activity. Unfortunatelly, information provided in official page of MediaProjection APi…
0
votes
1 answer

Can we programmatically dismiss the screen cast message in android? When MediaProjection.getScreenCaptureIntent() is called?

Is it possible to programmatically dismiss the screen sharing prompt message that pops up when we call MediaProjection.getScreenCaptureIntent()?
0
votes
1 answer

Can we edit the screen cast message in android? Current text - "exposing sensitive info during casting/recording"

Is it possible to edit the warning message that pops up when we start screen sharing in Android? The message is different for different OS devices. For OS 10 - Image for message shown in OS 10
0
votes
0 answers

Android ImageReader - Invalid format specified 42

I have been working to capture images of the phone screen using ImageReader. The JPEG's I am receiving are not valid. With this setting: ImageReader mImageReader = ImageReader.newInstance(width, height, ImageFormat.JPEG, 10); I get this in…
seanfir
  • 13
  • 3
0
votes
0 answers

Why i am not able to catch the error here when i run it crashed

My application is crashing automatically. whats wrong with this? i am working on music player application and its look everything perfect but somewhere the code is not matching properly and its crashing every time. class MainActivity :…
0
votes
0 answers

Using BroadcastReceiver to launch MediaProjection API on Android 10

I have been looking around for approximately 6 hours, I have never needed to ask a thing on StackOverflow because almost everytime I either come up with a solution or someone has already done it before. But this time, it got a little complicated for…
0
votes
1 answer

Record from a from a background-service using MediaProjection API: is this kind of approach the only one possible?

Intent dialogIntent = new Intent(BackgroundService.this, ScreenShotActivity.class); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dialogIntent); I want to ask you if starting the activity ScreenShotActivity.class,…
0
votes
1 answer

Is there a way to programmatically perform input action on system permission dialogs on Android?

This request is for a specific use case of a product Assuming I have an AccessibilityService instantiated as part of my application's context: I need to continuously capture screen content, for which i'm using a MediaProjectionManager attached to my…
0
votes
0 answers

How do I get a media projection manager without disturbing the current floating widget

I'm developing a screen recorder app that includes a floating widget. When users press on it, it calls the below code MediaProjectionManager mediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); …
0
votes
1 answer

Can I get MediaStreamTrack from AudioRecord?

I want audio share with webrtc in android. I try with MediaProjection, video share is OK. but, audio record have not Audio Track. How can I get Audio Track from Audio Record? AudioPlaybackCaptureConfiguration config = new…
Nocha
  • 3
  • 1
0
votes
1 answer

How to start Media projections from foreground service

Since I have changed SDK to 29 to be acceptable by Google Play Store I'm getting this crash when the user select screen recording Caused by: java.lang.SecurityException: Media projections require a foreground service of type…
Hossam Hassan
  • 795
  • 2
  • 13
  • 39