I want to take google map screenshot in my xamarin PCL Project. The map is displaying perfectly. But when i try to take a screenshot it is displaying a black screen for the map part. But extra part of the screen is capture perfectly. When i try to take screenshot from another app, i can take perfectly. I am using the below code.
My interface
public interface IScreenshotService { Task<byte[]> Capture(); }
`
public class ScreenshotService : IScreenshotService
{
public static Activity Activity { get; set; }
public async System.Threading.Tasks.Task<byte[]> Capture() { if (Activity == null) { throw new Exception("You have to set ScreenshotManager.Activity in your Android project"); } var view = Activity.Window.DecorView; view.DrawingCacheEnabled = true; Bitmap bitmap = view.GetDrawingCache(true); byte[] bitmapData; using (var stream = new MemoryStream()) { bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream); bitmapData = stream.ToArray(); } return bitmapData; }
}
`
Code to for calling function
byte[] screenshotData = await DependencyService.Get<IScreenshotService>().Capture();