I'm working on UI automation tests for an Android app. I need to save off a screenshot of the app as it appears during various steps of the test for later analysis by test engineers.
The usual way to do this in Android is to get the Window, then get the DecorView, then call onDraw with a Canvas backed by a Bitmap and save the Bitmap. This doesn't work when a Dialog is showing on top of an Activity, however. The Dialog and Activity each have their own separate DecorView.
Is there any way to programatically take a screenshot of the entire app with all windows composited? Unfortunately, the device is not rooted and the app does not have signature permissions, so this answer in another thread does not apply:
https://stackoverflow.com/a/13837910/244521
For phone devices: This article shares some tips that might help. However, on ICS and above, you may need to use Home + Power, not Volume Down + Power, as the article says.
For automated tests, perhaps AutomatedScreenshots will help
Related
problem:
My flutter app did not launch or more precise was stuck in launch screen because I had to many other apps in the background e.g. Gallery, Camera, Browser etc. and so on. After closing those sleeping background tasks my flutter app launched like expected.
Questions:
A) Is it possible to e.g. open a dialog and inform the user of the nature of the problem. E.g. close some apps, please. Your cell phone ran out of Memory? If so, how? There are alot „change splash screen“ tutorials, would this be the correct place to implement such logic or is another widget preferable?
B) I know closing other apps is not possible due to android OS restrictions. But may be someone has another idea to atleast inform the user about the issue?
Best regards
Hugo
I want to write a simple convenience app that allows me to have two locking modes on my phone. By default the phone would just go to the slide lock after a minute or two, but after a longer time or if I activate my app, it should engage a more stringent lock, such as the face unlocking. Basically when I have the phone on me, anything but the slide lock is overkill.
To do this I would have to read/write the preferences for the screen lock or find a list of available locking/unlocking mechanisms so I can select and invoke one of them. Does anybody know where this information can be found/is stored?
I expected the preference keys to be found in the (System.Secure class), but could not immediately find anything related except the LOCK_PATTERN_ENABLED setting, which would not be enough.
I tried searching for references to the FaceDetector class, but none are returned in my Eclipse.
The Device Administration API Sample looks like it might give some leads if I could look at the source code. Unfortunately the page omits the detail of which of the several folders of each of the sample directories for the approx. 10 API levels supporting I need to download and look in, as far as I can see.
You can change lock modes in your app only if it is a device admin. These API are located in class DevicePolicyManager and methods setMaximumTimeToLock() and lockNow() etc. It is only accessible only if your app is a device admin. If you are interested in crating a custom lockscreen app, you can try this.
I know this question is ask number of times but wait i am asking something different.
I follow this post and able to take screen shot. but is it possible to take screen shot when my application is closed.
Supposed i set timer like after 1 hour and i close my app. Then exactly after 1 hour device need to take a screen shot whatever on a screen.
Is this possible with Background Services?
I already follow code and also did some research but is this possible?
Is it necessary to root device to take screenshot.
Please give me any hint or reference.
Thanks in advance.
Try using : call the methods in this library from service.
http://code.google.com/p/android-screenshot-library/
Android Screenshot Library (ASL) enables to programmatically capture screenshots from Android devices without requirement of having root access privileges. Instead, ASL utilizes a native service running in the background, started via the Android Debug Bridge (ADB) once per device boot.
DeveloperGuide
UPDATE:
The method mentioned in your reference will not work in that case, as it reads the view that are drawn and in application context. where as if application is closed then you cant get that context.( at-least on non rooted phone).
On rooted device you can read complete frame-buffer so no need to worry about the application context.
I did tried to use the ASL once and it worked out good for me.
I'm looking for some help from developers who are know android development. We have a client who wants to use an Android tablet as a means of collecting data when someone walks into their office. The problem is that they don't want any of the background functions or access to the net on the device (it's there to log people in so it should not move from that function with out some other credentials to "unlock" the device.)
With apple I know you can lock the screen on to a page/app but not sure about android? Can't find any thing online that would tell me it can be done on android.
With Android you can replace the launcher (home screen) app, and if that app doesn't give you access to launching other things, then you cannot do other things. The first time you press the home key after installing another launcher candidate, Android asks you which home screen application to run (the original or your new one) and allows you to set your answer as the default, eliminating the question in the future.
I'm quite new to Android programming but familiar with C/C++ and Linux enough to program a few stuff. In my next project, I've to run some native application (Linux applications) under Android.
The executable I'm calling is using the framebuffer device to produce screen output. When I try to just call the program the output of the program is lost because Android is redrawing the screen, thus overwriting the framebuffer.
In order to prevent this, I made a "stubbing" Android program, which actually has no window design (just a black screen) but calls my program. This is working good to some extend; however, whenever I rotate the screen, or some Tattoo notification comes, Android redraws the screen and we're back to frame #1...
Thus, I wondered if there is a "low level" API or something, which can prevent Android from using the screen at all, as long as I release it. Shortly, like a WakeLock preventing phone from sleeping, I want a 'Lock' which will lock the screen (framebuffer device) completely. Does anyone know how can I achieve such functionality?
PS: This might have something to do with SurfaceFlinger, but I've read somewhere that it doesn't publish any API to user-level.
On Android the screen belongs to SurfaceFlinger.
The executable I'm calling is using the framebuffer device to produce screen output.
That's not supported.
Thus, I wondered if there is a "low level" API or something, which can prevent Android from using the screen at all, as long as I release it.
Nothing that is supported at the SDK or NDK levels. You are welcome to create your own custom firmware that does whatever you want, and load that custom firmware on your own device.
Otherwise, please use a supported means for interacting with the screen (e.g., OpenGL natively in C/C++).