Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I take screenshot of main screen in android programmatically?

 
Zubin Methew
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to take screenshots of main screen through my application. I am using the following code but it gives an image of 0Bytes. Please let me know that what I am doing wrong .


Any kind of help would be appreciated. Thanks in advance.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic