Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any reason why I cannot take a screenshot of my app with ICS built-in shortcut?

At first, this might not seem the proper place to ask this... But since I've only noticed this problem with my own app, I guess there's no other place to ask it. Maybe I'm doing something wrong, but I have no clue what...

As you are probably aware, ICS allows you to take a screenshot of the screen pressing Power + VolumeDown. I own an HTC One X and the shortcut is Power + Home. I don't know if this changes anything (maybe someone with a Galaxy Nexus could try it out).

My own app, Notification Agenda (I'm not going to link it so I'm not accused of SPAM or something similar but there's really no way I can post this question without self-advertising my app cause), doesn't allow me to take screenshots with the above key combination with my One X. I can take screenshots of any other app but it doesn't work on my own...

What the hell do you think I'm doing to "disable" this? My app is very simple and there's not much going on for this to happen. Any ideas?

Every time I try to take a screenshot of my app, I get this in logcat:

08-24 00:15:40.570: E/InputManager-JNI(277): An exception was thrown by callback 'interceptKeyBeforeDispatching'.
08-24 00:15:40.570: E/InputManager-JNI(277): java.lang.StringIndexOutOfBoundsException: length=83; regionStart=-1; regionLength=83
08-24 00:15:40.570: E/InputManager-JNI(277):    at java.lang.String.startEndAndLength(String.java:593)
08-24 00:15:40.570: E/InputManager-JNI(277):    at java.lang.String.substring(String.java:1474)
08-24 00:15:40.570: E/InputManager-JNI(277):    at com.android.internal.policy.impl.PhoneWindowManager.interceptKeyBeforeDispatching(PhoneWindowManager.java:2375)
08-24 00:15:40.570: E/InputManager-JNI(277):    at com.android.server.wm.InputMonitor.interceptKeyBeforeDispatching(InputMonitor.java:307)
08-24 00:15:40.570: E/InputManager-JNI(277):    at com.android.server.wm.InputManager$Callbacks.interceptKeyBeforeDispatching(InputManager.java:663)
08-24 00:15:40.570: E/InputManager-JNI(277):    at dalvik.system.NativeStart.run(Native Method)

That doesn't happen when the screenshot works. Instead a bunch of other calls to the screenshot app and many other things are logged.

Why is my app preventing the screenshot and generating the error above?

like image 541
rfgamaral Avatar asked Aug 23 '12 22:08

rfgamaral


People also ask

Why do some apps not allow screenshots?

Android may be a wide-open world compared to iOS, but there are still some things you just can't do on Google's mobile platform. One of them is capturing screenshots within apps that prohibit the act — either because the screen contains sensitive information or content protected by digital rights management.

How do I take a screenshot when an app doesn't allow iOS?

The shortcut you need is Sleep/Wake+Home, which will save a screenshot in your Camera Roll and in the native Screenshots album, ushered in with iOS 9. Alternatively, you can connect your iPhone or iPad to a computer and capture the screen from there.


1 Answers

One thing that can cause this is for FLAG_SECURE to be turned on for your window. http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE

like image 193
Dave C Avatar answered Sep 22 '22 15:09

Dave C