Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Android take screenshots?

I know HOW to take a screenshot, but I was wondering how it works.

At least since Android 4.0, you have been able to take a screen shot by holding down both the volume-down + power keys on the phone, and Android will capture the current screen and save it to the SD card.

I'm just wondering if anyone knows HOW this works, as in, if it's a service constantly running in the background, or something built into each app, or . Also, where is it located in the source code of Android?

Thanks!

like image 673
Patrick Mahoney Avatar asked Nov 01 '12 15:11

Patrick Mahoney


2 Answers

Browsing through the sourcecode i found the section that listens for the key combination and starts the process:

Here's the specific code:

http://androidxref.com/4.1.1/xref/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#3270

like image 121
John Boker Avatar answered Oct 21 '22 05:10

John Boker


I just found the code in the source tree here: https://github.com/android/platform_frameworks_base/tree/master/packages/SystemUI/src/com/android/systemui/screenshot

I guess it's just a matter of reading through it to get a better understanding of the process.

like image 31
Patrick Mahoney Avatar answered Oct 21 '22 05:10

Patrick Mahoney