Android - Take a "Screenshot" of an App Running in the Background - android

I have read plenty of questions that deal with an app taking screenshot of the current users screen while the app runs in the background, but have not seen many articles that deal with the app taking a "screenshot" of itself while it runs in the background.
I would like this to be able to be done without having to root the phone in any way as I would like the app I make be available to everyone(rooting is probably not involved in this solution, but just throwing that out there).
The end goal of the app is for the app be able to take a screenshot of itself and save that screenshot as the users background wallpaper. There are several other features I would like to add, but I would just want to know, is this even possible? If this is, could anyone show me some starter code or link me to some?If this question has been asked before, please let me know, otherwise, any and all help is appreciated. Thank you!

Firstly, I am not really sure if I understand your requirement correctly. Ideally when the app is in background, its state when it went to the background and while it is in background will remain the same. So you can take a screenshot of your app, when the app is just going in background, which can be handled in your onPause() of the activity.
To take screenshot of your app, place the entire layout in a ViewGroup and then use the following code.
parentLayout = (RelativeLayout)findViewById(R.id.parentLayout);
parentLayout.setDrawingCacheEnabled(true);
parentLayout.buildDrawingCache();
And when you want to take a screenshot, get the screenshot in the Bitmap by using
bitmap = parentLayout.getDrawingCache();
The above line should be in your onPause() thats when the app goes in background. Or you could also trigger it when your app is in background, and see if it is captured. I'm not really sure how it will work in the latter scenario.

Related

Take screenshots from other apps as image source

I'd like to offer an app to modify images. In order to have the user give an easy access to the that feature, it would be the easiest solution to just let him directly take a screenshot to have the source picture taken or respond to a screenshot event and access the latest screenshot.
Unfortunately it seems to be a problem, since an app or even a service from the app runs in background cannot easily react to events and I haven't found any solution that would go only little close to that kind of thing.
So my questions are (lets assume all necessary permissions are given from the user):
Is there a possibility to register my app as kind of standard screenshot app (or additional screenshot app triggered by another key combination of the device) and how ;-)
Can an app stay in a state to notice if a screenshot is taken and
can access it?
If not: Any ideas for an workaround other than let the user select a taken picture, which is rather kind of roundabout and annoying?
Any hints are very welcome! Thank you in advance!
(Since I had a misleading headline, I reposted this question - sorry!)

How do you display hint circles in Android?

I'm wondering how to display the "hint circles" (I don't know what they're really called, and I couldn't find it anywhere) when opening an app for the first time. I've seen this in many stock android apps, but not in many third party apps. Is there even a way to do this?
Thanks!
Here is a picture of what i mean. (The blue circle with the OK, not the white one)
there is a library for that, check ShowcaseView
From what I have experienced with these, they seem to just be a form of a splash screen, or another image overlaying the actual app. Even if the stock apps don't handle it like that, couldn't you just have the app open up a new screen that contained a mostly transparent image except for where you want the ring or other hints. Then you can just at a button to that screen, so that after the user has read all of the hints, then they could close the screen.
I do not know how to totally do this, but since you said you couldn't find any documentation on it, I figured this could either give you a solution or point you in another direction to keep looking.

Manipulated Underlying Apps or Android OS

My initial question dealt with building a translucent view that allowed manipulation of a view below it. Bluefalcon did an excellent job answering this and helped me understand view mechanics a little better:
How can I interact with elements behind a translucent Android app?
I'm still unsure of how to manipulate an underlying view that is not part of my app. The effect I'm trying to achieve is like the Screen Filter App:
https://play.google.com/store/apps/details?id=com.haxor&hl=en
In this app, once started, it seems a "filter" view is placed on top of everything but you can still interact with whatever is running under it. The app store, email, home screen etc.
I currently have getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); in my app's onCreate method. This seems to get close. If I swipe on my app nothing updates, but when i back out of the app the home screen updates as if i swiped.
Any help will be greatly appreciated!

to get a current screen view from my own application

I am running one external application from my own application and when this application opens, i want to get a view of that external application in my own application. So that i can capture a screenshot of it. Please help me in this.
I dont think thats possible. The communication between applications or even activities is limited to passing data to each other through intents. I don't think sharing references to objects across applications is possible. Please correct me.
Such a thing would be possible if they allowed you to launch an external application in your own window.
I did some search and it is quite likely it may not be possible, however I have found a possible way. Take a look at this link, which states that
Or If you want to take a ScreenShot of your current device screen (any
application) then you have to root permission, and read framebuffer
for that which will give raw data of current screen then convert it to
bitmap or any picture file you can do it in your service.
Which means that whenever your application starts an application you will need to create a service that reads the framebiffer, but if an activity is used for taking the screenshot then it will not be useful because the screenshot will then be of that activity.
See this and this, these links are related to your question as well. And see if it works.
Hope this helps.

How to take a screen shot in android

I want to take a screen shot in android irrespective of the application and without rooting the phone. I have seen into the previous thread link
I followed this instructions but they are specific to one application. And we need to change the layout file of every application.
I also came across the link which is a library. One thing which is not clear to me in this is that whether the manifest.xml file should be changed for every application.
Can you please let me know if any other ways are possible? I know this is a security issue but if the application doesnt mind I need to take the screen shots.
Thanks.
if you don't need the status bar (or keyboard) you can do this in your activity:
View root = findViewById(android.R.id.content);
root.setDrawingCacheEnabled(true);
Bitmap bm = Bitmap.createBitmap(root.getDrawingCache());
root.setDrawingCacheEnabled(false);
Completely untested but it should work.
After seeing your comment about taking screenshots of other applications I do not believe that what you want is possible without rooting the phone.

Categories

Resources