1

I'm trying to use MediaProjection API

https://developer.android.com/reference/android/media/projection/MediaProjection.html

To Save Data To a series of pictures.

All that i could find on the web was guides that use a Surface, and they cast the MediaProjection to a surface.

All the guides i could find started an intent for the result

  startActivityForResult(
                    mMediaProjectionManager.createScreenCaptureIntent(),
                    REQUEST_MEDIA_PROJECTION);

and then just mirrored the MediaProjection Data to a surface

mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture",
        mSurfaceView.getWidth(), mSurfaceView.getHeight(), mScreenDensity,
        DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
        mSurface, null, null);

Is there a way i can mirror the screen directly to an Image file and then save the Image file periodically ?

Or a different way to save the data form the MediaProjection object directly to images instead of showing it on screen ?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Chief Madog
  • 1,738
  • 4
  • 28
  • 55
  • There are more examples on the Web than that, such as [this one](https://github.com/commonsguy/cw-omnibus/tree/v8.7/MediaProjection/andshooter) and [this one](https://github.com/commonsguy/cw-omnibus/tree/v8.7/MediaProjection/andprojector), covered in [this book](https://commonsware.com/Android). There is nothing very special about doing this from a service, so please edit your question and explain **in detail** what you tried and what specific problems you encountered. – CommonsWare Aug 09 '17 at 14:04
  • Thnx @CommonsWare i Edited my question and it's much clearer now – Chief Madog Aug 09 '17 at 14:15
  • "Is there a way i can mirror the screen directly to an Image file" -- use an `ImageReader`. This is demonstrated in both sample apps that I linked to previously. – CommonsWare Aug 09 '17 at 14:24

0 Answers0