Is there any way of saving the screenshot taken by MonkeyRunner's device.takeSnapshot() to the phone's internal storage itself? This example I have seen on the net only saves it to the computer where the MonkeyRunner command is executed.
http://www.vogella.com/tutorials/AndroidTesting/article.html#monkeyrunner_example
Try using:
device.shell('screencap -p /sdcard/sc.png')
this will save the screen capture to your sdcard.
Related
I'm manipulating the Android device in an ADB session, fetching back the screenshots captured by command screencap -p /sdcard/image.png.
Due to the very limited network bandwidth, I want to resize the captured png file to a smaller one, before sending it back through the network.
How to do such a resizing using ADB command? I already found some additionally installed apps could do this for me, but that requires a manual operation to open that app, and resizing the image through its GUI functionality. But how to do it pragmatically? in a ADB command manner?
You can compress the images while you are capturing them, this would have the advantage of keeping the same resolution when you uncompress.
$ screencap -p | gzip -c9 > myscreenshot.png.gz
Then you can transfer the compressed file and uncompress it to obtain the original image.
I am a bit confused on where and how Camera images get stored. So I have an API 22 emulator ran on an SD and the below code will only work if ran using an SD card. I then take a couple of pics and see the pictures in the gallery and the camFiles array will get populated.
However, it does not work with API 23/24 emulators even with SD card. Is there a way to get the default camera directory that'll work for any API level?
File cameraDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString());
File[] files = cameraDir.listFiles();
//gets the 'Camera' directory
File finalCamDir = files[0];
File[] camFiles = finalCamDir.listFiles();
Is there a way to get the default camera directory that'll work for any API level?
Not really. There is no single "default camera directory". There are thousands of Android devices, with hundreds of different pre-installed camera apps, in addition to camera apps that users install themselves. It is up to the developers of those camera apps to decide where to save photos on the device.
DIRECTORY_DCIM is a recommended starting point. Some camera apps will put photos directly in this directory. Others, such as Open Camera, will use a subdirectory off of DIRECTORY_DCIM (e.g., OpenCamera/). Others are welcome to store their photos wherever they want, not necessarily involving DIRECTORY_DCIM.
HelloEveryone! I want to know some principal thing. Is there exists a method to take a picture (with good resolution) from android device without saving it in hard memory (only in RAM). I tried to:
use TakePicture(shutter, raw, jpg), but resolution of the resulting JPG is very low and RAW working with very few number of devices. Was asked here
give the control to Google Camera, but this way required some temporary file in the hard memory (to write picture)
How can I do this. Or is it impossible? Any help! Thank you!
It depends on your phone. Many phones do not need external sd card because they already have a internal one. So I suggest you check the hardware information of your phone first. If it do not have a external sd card, you can try to use camera2
to take videos and pictures. Pictures and videos can be stored in RAM. But if you want to access the pictures stored in RAM, you need to root your phone first.
In my application i have to use camera to take picture and analize, but i dont have a webcam with my PC.
In this application after taking a snap it automatically start analizing
Is it possible to use any picture stored in my pc to treat it as taken from camera for continuing the further process ?
thanks
You should load this picture to the sd card of the emulator and then access it, analyze it, etc. You can't access directly from your pc.
I see how to mount an SD card in the emulator, but I'm not sure how you move files back and forth between the userdata image and the SD card image. Can someone tell me how to do this?
The first thought that comes to my mind is to first transfer the data from the userdata image file to local filesystem and then transfer back from local to sdcard image.
adb pull /data/data/com.example.sample ./sample/
adb push ./sample/ /sdcard/sample/
hope I interpreted your question correctly.