0

I need to develop an Android app without UI (using a background service) which will run indefinitely. The service will capture screenshots every second i.e whatever actions user performs on screen will be captured as a screenshot and stored in either the phone's internal storage or SD card. Screenshots will be replaced and only the last updated screenshot will be stored so there's no issue with storage limitation. I read about Android Services and IntentServices but I'm not able to figure out the best option for my case. How do i proceed with this? Or is there any other way of doing this without using a Service/IntentService?

Kane O'Riley
  • 2,482
  • 2
  • 18
  • 27
Assassin
  • 215
  • 1
  • 4
  • 13
  • did u check this -http://stackoverflow.com/questions/7762643/android-take-screen-shot-programatically – Mayuri Sep 09 '15 at 07:24
  • I realise my answer probably isn't useful when your capturing the screenshots so frequently, but it is the easiest way to initiate a proper screenshot. To do what you're asking would probably require grabbing the framebuffer directly and converting it to an image, which I don't have experience with or know the feasibility of. – Kane O'Riley Sep 09 '15 at 07:53

1 Answers1

1

For my application I used the following:

public static void takeScreenshot() {
    ShellInterface.runCommand("input keyevent " + KeyEvent.KEYCODE_SYSRQ + " &");
}

Where obviously ShellInterface.runCommand() , is my utility method for running root commands. KEYCODE_SYSRQ functions as a print screen button, and in my testing works on the majority of devices across Android versions. Even Samsung didn't break it!

Note that this invokes the core system screenshot function. So whilst it works for all applications and will truly capture everything on the screen, it doesn't give you the ability to choose where to save it, so you'd probably have to watch the file system to find out when a file is added and act accordingly.

Kane O'Riley
  • 2,482
  • 2
  • 18
  • 27