From Gingerbread onwards there is a built-in OS facility for taking screenshots (on non-rooted phones as well).
By pressing home and power button together and it also saves it to a folder on the SD card.
Is there a way to invoke this via code? The ability to take a screenshot is needed as part of my other app. There is an app named screenshot-UX that has a method called embedded screenshot capture, which I believe invokes that.
Does anyone know how to invoke the built-in Gingerbread screenshot facility or even how to use it? (with having optional parameters like save path, extensions etc..) as well as for non-rooted phones.
This is not a built-in feature of the Android platform at the Gingerbread (2.3) level, although some OEMs did include it (Samsung, for instance, has you press HOME and BACK at the same time). It was not introduced to the platform as something users could do with a button sequence until 4.0, where the sequence is now to press the Power and Volume buttons at the same time.
Even still, there is no public API via which developers can take screenshots. The way that screenshot apps capture images Android devices is to read the frame buffer directly via the SurfaceFlinger in native code.
Related
I am creating an application for tablet in android where, I want to use usb camera as a default camera when I start my application. I want to click picture and save them in either jpeg,jpg or png format. I could not find any helpful resources on web. How can I implement such functionality? Any help would be appreciated.
The solutions are all complex with advantages and disadvantages. Information on USB and UVC is freely available from the USB IF web site, although there are many hundreds of pages of detail. The main issue is that the isochronous transfer method is missing from the Android framework, although descriptor retrieval, control, interrupt and bulk are implemented. Hence, most of the usb access can be done in Java or Kotlin, but the streaming side is a real pain. Using method one below and a Logitek C615 webcam, I obtained 640x480#30 fps on a Lenovo Tab10 using Android 6, and 1920x1080#30fps on a Lenovo IdeaPad 520 Miix using Android9 x86. The Tab10 appears to run at USB v1 speeds although it has a USB v2 micro-B socket. The Miix has a type A USB socket and does not need an OTG converter. I know of three methods:
Use Libusb. This requires a separate compilation and build in Android Studio to a shared library. Write C++ code to setup, transfer packets and teardown the webcam. Write Java code for the user interface, decompress MJPEG, display preview and write JPEGs to storage. Connect the two via JNI. The C++ and Java run in separate threads but are non blocking. The inefficiency is in memcopying from a native image frame array to a JNI array and then freeing for garbage collection after each frame. Android apps run in a container, which means a special startup for Libusb and some functions fail, probably because of selinux violations.
Use JNA to wrap the Libc libray. JNA is obtained from a repository and does not require a separate build. Libc is in Android Studio. All the code is Java, but IOCTL is used to control the usb file streams and the small stuff is really sweated. Libusb does much of the low level stuff in design choice 1.
Use the external camera option with the Camera2 API. Non of my devices support an external camera, not even my Samsung Android 13 phone. I suspect this is meant for systems integrators to build custom versions of Android with the appropriate settings as documented by Google, implemented on SBCs for point-of-sale etc.
I would like to write an application which can programatically generate touch events on the phone.
I have already tried this methods:
adb : adb swipe and so on... It requires USB cable and connect the phone to pc
adb ON TCPIP: same
My problem with adb is to require so much presetting by user and I don't want to make the user to learn it. I have already made an application which use adb, but it's difficult for the user to set up properly :(
I have heard and I tried to sign my application with platform sign, but it's not good for me, because I would like to publish my app on android market and it is not a system application...
I would like to find a way to achieve this in a single application which can produce touch outside of the app (from background) and I would like to publish on market.
I have found this application: https://play.google.com/store/apps/details?id=com.teamviewer.quicksupport.samsung which can basically do this. Because when I click on my computer, it send a message to the phone and the phone make the touch on the screen. How and with what privileges can teamviewer do it?
Please give me some advice about it.
I would like to find a way to achieve this in a single application which can produce touch outside of the app (from background) and I would like to publish on market.
This is not possible, outside of what little input faking can be done by an accessibility service.
How and with what privileges can teamviewer do it?
If your read that Play Store listing, you will notice that it only works with Samsung devices. That is because the makers of TeamViewer struck a deal with Samsung to enable this sort of integration. Similarly, the TeamViewer team struck deals with a few other device manufacturers. However, they did not do so with all manufacturers, and so TeamViewer does not work on all devices.
Have a look here .This might be useful.
InputInjector
Android library that eases the process of injecting InputEvents (MotionEvent, KeyEvent) to you Android app. The library uses internal API calls to inject events and depend on the accessability of these. This library will therefore not work on all devices but theoretically support Android 2.3 and forward (API level 9-18+).
Androd 2.3 (API level 9-15)
In older versions of Android we envoke the same system calls as used by the Instrumentation framework.
Permission No special permission needs to be set.
Androd 4.1.2 (API level 16 and forward)
As of API level 16 we have access to the InputManager class. We use this as the basis for the input injection.
Permission Using InputManager for injection requires setting permission android.permission.INJECT_EVENTS in your manifest.
Using this permission may require altering Lint Error Checking in order to be able to compile. In Eclipse this is done by going to Window->Preferences->Android->Lint Error Checking and then finding ProtectedPermissions and setting severity to something else than error.
NOTE: In order to inject events to other apps using InputManager, your apk must be signed with system level certificate.
https://github.com/arnebp/android-inputinjector
Is there a UI package that works on both Android and desktop Java? I am wondering if a package exists that can either be handed a window or activity and will display user defined graphics with a identical interface on both Android and a PC.
The end goal is to have code that works both on android and a PC with very minor to no modification either way. A tool such as Bluestack is not what I am looking for because it requires installation on the users end.
I do not think this is possible.
You can install the android sdk + emulator and run the apk on the desktop, but then you have already expressed your wish not to install anything on the client side.
Considering your requirement (identical interface, minor to no modification, no user installation) I would say your best bet is a web application with a mobile view css.
It turns out that JGame was more or less what I was looking for. It runs fine on both desktop java and android devices.
In Android/Java, Is there any code example to capture the screenshot of a computer with good frames per second programatically and create video?
I'd like a tutorial or full source code to do this. I'd like the program to work with and without the device having been "rooted".
There is app in the play store called Screencast Video Recorder that does this. But you need to ROOT the device for it to work, so I know it can be done.
What's the best way to capture android screenshot and create a video programmatically on a non-rooted device?
There is an app called Telecine that is open source that allows you to record screens - the code can be found at https://github.com/JakeWharton/Telecine. All credit is to Jake Wharton.
If you need an example, you can find one at Commonsware's github page - Mark Murphy has provided a sample app for both screen capture and screen recording using the MediaProjection APIs.
you can capture the screen via using DDMS as adb runs and has permission to the framebuffer:
follow this link for more details :
http://thetechjournal.com/electronics/android/how-to-capture-screenshots-and-record-video-on-android-device.xhtml
ALSO
check this links may be get some ideas about what you need :
http://answers.oreilly.com/topic/951-how-to-capture-video-of-the-screen-on-android/
http://www.mightypocket.com/2010/09/installing-android-screenshots-screen-capture-screen-cast-for-windows/
and check this project :
http://sourceforge.net/projects/ashot/
hope this help .
Check the following link
https://code.google.com/p/java-remote-control/
in this project the owner has created a java remote control i.e. he has captured the images from the remote computer and transfer to server and convert it to movies with different format all you need to understand what he has done and implement the same for all your needs. you can access the full source code with SVN client from the following URL
http://java-remote-control.googlecode.com/svn/trunk/
Also you can look for the Remote class in java which provides createScreenCapture method
As of Android 4.4, there is a screen recording feature accessible via adb.
http://developer.android.com/tools/help/adb.html#screenrecord
The screenrecord command is a shell utility for recording the display of devices running Android 4.4 (API level 19) and higher. The utility records screen activity to an MPEG-4 file, which you can then download and use as part of a video presentation. This utility is useful for developers who want to create promotional or training videos without using a separate recording device.
Try this application from the market
https://play.google.com/store/apps/details?id=com.ms.screencastfree
** Does not work on Galaxy Nexus or Tegra 2/3 yet **
EDIT 28/11/2014
Lollipop has been released and provides a new Screen recording API
http://developer.android.com/about/versions/android-5.0.html#UI
Screen capturing and sharing
Android 5.0 lets you add screen capturing and screen sharing
capabilities to your app with the new android.media.projection APIs.
This functionality is useful, for example, if you want to enable
screen sharing in a video conferencing app.
The new createVirtualDisplay() method allows your app to capture the
contents of the main screen (the default display) into a Surface
object, which your app can then send across the network. The API only
allows capturing non-secure screen content, and not system audio. To
begin screen capturing, your app must first request the user’s
permission by launching a screen capture dialog using an Intent
obtained through the createScreenCaptureIntent() method.
For an example of how to use the new APIs, see the MediaProjectionDemo
class in the sample project.
I am developing a Java ME application which uses the camera to take a snapshot and then decodes it (using ZXing library). The target is Nokia phones.
I need to use the focus to have a clear image, if not, it is difficult to decode the image.
Since the Series 40, the control "videocontrol" and "SnapShopControl" are available. I thought that for the "FocusControl" it was the same, but it isn't.
I discovered that it is almost non-existent, not only for the Series 40 (only some phones), but (more surprisingly) for the Series 60 and Symbian 3.
You can see that in Java ME API support on Nokia devices.
These mobile phones support JSR-234 but for audio and music, not for camera.
As you can imagine, this is very deceiving, Nokia is not doing their work well.
Did you find any solution? Perhaps another "made-by-hand" control? I am afraid I have to start programming in C++ because I haven't got much time.
The solution has been to use Nokia's APIBridge (an extensible mechanism to access device features in WRT, Flash Lite, and Java applications). You can access the software is installed in the phone for the camera and if it is able to use the autofocus, you can use it, and it returns the image you take.
See Tool details for APIBridge for further details.
The implementation is easy (you install the SIS file for the APIBridge in the device, and you can package your application and this SIS file together).
You use the following code:
APIBridge bridge = APIBridge.getInstance();
bridge.Initialize(midlet);
NewFileService service = (NewFileService) bridge.createService("service.newfileservice");
Hashtable filter = new Hashtable();
filter.put("NewFileType", "Image");
BridgeResult res= service.TakePhoto(filter);
Many phones' hardware just don't support focus. Some Sony Ericsson phones (e.g. G502) support FocusControl, but they don't allow to do anything because the hardware does not support it.
I'm afraid to say that you can do probably nothing with this problem in Java ME.
If the phones support focus control, but it is not availble in Java ME, there are probably two ways how to solve it:
Let user to use the builtin camera and load it (preferably the last photo) from Camera album.
Try to use camera focus from a S60 API.
Note that I'm not a S60 developer.