Android Take Screenshot of Surface View Shows Black Screen

前端 未结 4 1752
花落未央
花落未央 2020-11-22 04:58

I am attempting to Take a Screenshot of my Game through code and Share it through an Intent. I able to do of those things, however the screenshot always appears black. Here

4条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 05:51

    I know its a late reply but for those who face the same problem,

    we can use PixelCopy for fetching the snapshot. It's available in API level 24 and above

    PixelCopy.request(surfaceViewObject,BitmapDest,listener,new Handler());
    

    where,

    surfaceViewObject is the object of surface view

    BitmapDest is the bitmap object where the image will be saved and it cant be null

    listener is OnPixelCopyFinishedListener

    for more info refer - https://developer.android.com/reference/android/view/PixelCopy

提交回复
热议问题