I have looked at probably every SO article concering capturing the screen (screenshot, screendump) programmatically on Android, and they usually all end up with the same ans
use this library .... it works great for me.
https://github.com/jraska/Falcon
// Saving screenshot to file
Falcon.takeScreenshot(this, imageFile);
// Take bitmap and do whatever you want
Bitmap bitmap = Falcon.takeScreenshotBitmap(this);