This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The code you posted would require the phone to be rooted, and probably requires super user privileges. Do you need a screenshot of your application or a screenshot of the phone (even stuff not in your application)? I think taking a screenshot of your application can be done by painting the root view onto a bitmap. I don't know if you can take a screenshot of the phone (outside your application) without super user privileges or some work around (a quick search identified a means using a service the user would have to start from a PC via the Android SDK... but that hardly seems reasonable.)