• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
reply
    Bookmark Topic Watch Topic
  • New Topic