android - capture of the entire screen programatically - java

Is it possible to capture the entire screen from Android application code? I'm developing an application like VNC for Android platform.
Regards

I think that depends on what you are trying to capture. I'm sure you can use Moss's method to create a screenshot from your own application - that is, something you render yourself.
As I understand it however, capturing from other views, apps, etc. is designed to be impossible for security reasons. This is to avoid apps being able to take screen shots from other apps, which would make it easy to steal sensitive data.

yes it is. You just need to create a canvas and assign it a Bitmap, then draw to that canvas instead of the canvas you use in your onDraw method and save the bitmap on the SDcard for example.
Just to renind you that this method will work if you handle the drawing, so you should use a custom home screen for it to capture wether you want. (just get the default android home screen :D).

I don't have personal experience with it, but this open source project sounds like it might either solve your problem, or provide you clues as to which API to use:
http://sourceforge.net/projects/ashot/
Screen capturing tool for Android
handsets connected via USB to a
desktop/laptop. It is great for
fullscreen presentations, product
demos, automatic screen recording, or
just a single screenshot. Without
root.

Related

How To make Video Background transparent In ExoPlayer Android

I want to remove background color of video in exoplayer or make it transparent i.e if video background color is red then make it transparent and view behind exoplayer must be visible.
Note : I don't want to make changes in Exoplayer background only remove video background which is playing in ExoPlayer
I have made lots of search in google but unfortunate did't got right answer, Please let me know its possible or not and its possible using any other way please direct me.
Thanks in Advance
Exoplayer is not really designed to modify a video file like this while displaying it.
Given that the background may change from frame to frame, I suspect you may find it hard to find any solution that will be able to do this quickly enough on any regular Android device, as there will likely be quite a bit of video processing involved.
If your background is static, like the room behind the speaker in a Zoom or similar conference call, then it may be a bit easier and you could look at OpenCV background substitution techniques:
https://opencv24-python-tutorials.readthedocs.io/en/latest/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.html
Most of the examples will be in Python so you will have to explore support in Android OpenCV, which is usually a subset and can be a little tricky to set up (check Q&A on SO for this). Android OpenCV also still uses Eclipse rather than Studio in the documentation at the time of writing, which is something to be aware of.
If you have the luxury of removing the background on the server side before you stream the video to the Android device then things will be easier and you should be able to find up to date example using Python and the OpenCV techniques linked above.
If you use case is a 'Greenscreen' background example, then ffmpeg can also provide you filters to change the background as you wish, including making it transparent. The documentation is here: https://ffmpeg.org/ffmpeg-filters.html#toc-chromakey
It includes an example to change the green screen to transparent in an image (png image in this example):
ffmpeg -i input.png -vf chromakey=green out.png

How do you auto-rotate a captured image using Phonegap?

I'm working on an example I got from Phonegap on capturing Images using the built in device camera. If I rotate the device, the saved image stays in that orientation.
I know in javascript, I can manipulate images-- and Phonegap has a G-Calibration sensor api I can use.... but Is there a straight forward way through Phonegap to auto-detect orientation?
the problem is that the exif data (which contains the orientation among other things) is not passed by the plugin.
For this reason you need to try to understand which "way" the picture was taken.
Worst case, allow the user to rotate it.

Accessing hardware buttons within the camera app

i wish to write a plugin that will enable me to access hardware buttons of the phone while using the camera app. how would i go about doing this. or is it even possible.
Sorry, you can't generally do this. There are some keys that applications can respond to while in the background (specifically the media play/pause/etc buttons) but it is not generally possible to process key events while another app has focus.
Your best best is to check the Camera source but you might consider making your own app based on Camera.

Is it possible for an Android app to modify the screen at all times?

To give a ridiculous example, could you have a water app/service that stayed on the display AT ALL TIMES (or perhaps only when not actively using another application) and caused ripples to occur when you touched the screen? I would not want an app like this, but it's just an example.
I know there is a live wallpaper for this, but it is in the background. What if you wanted the affect on top of your icons and widgets and UI as well?
Is this possible?
Is this possible?
If you write your own firmware, yes. Android SDK applications cannot do this.

Possible to 'layer' Android applications?

I know this in general is beyond the scope of SO, but I am looking for some basic yes/no info to see if it is even feasible to proceed... I am thinking about building and Android 'note-taking/annotation' app that runs 'over' other installed Android apps, such as the web browser for example.
Essentially, while the user is browsing, my app would be running in the bg as a service, and then they could activate it which would then essentially intercept user inputs and translate those on a transparent canvas over the web browser into lines, shapes, etc. The user could then take a screen-cap of their marking with the underlying web page, which would be stored to the sd card.
This is a very good idea and a great question, but sadly, I do not believe it is possible.
The way Android is designed only one Activity can have focus at a time, while a Service could run in the background, the user would not be able to interact with it. The user can only interact with the currently active Activity.
Again, love the idea, but it is sadly not supported.
You might be able to achieve this with the WindowManager service. You can then use that to call addView() with a view of type TYPE_SYSTEM_ALERT, or possibly TYPE_SYSTEM_OVERLAY (but see the notes in the documentation about taking input focus).
I haven't tried it myself, but I've seen several apps (often dictionary apps that translate whatever words you tap on) that do overlays, and they always seem to require the SYSTEM_ALERT_WINDOW permission.

Categories

Resources