Android Tutorial How to make screenshots!

magarcan

Active Member
Licensed User
I think one of the easiest way is using Android SDK tools. I'll explain this method using Windows, but in Linux or Mac should be similar. This is what you have to do:
-Connect your mobile to computer with usb cable

-Open your SDK folder.


-Go to tools folder
-Execute ddms.bat
-Your Device must be Online


-Go to Device>Screen capture... or press Ctrl-S


-Press Refresh in order to update your Screenshot.
-Press Save to save your Screenshot.
 

Erel

Administrator
Staff member
Licensed User
Great tutorial. I will add a small tip.

Here is an excellent open source screen capture program: zscreen - Advanced Image/Text/File utility that allows for region/window/full-screen screenshots, text services and file hosting - Google Project Hosting
It allows you to select parts of the screen and it has many useful features. For examples I've configured it to automatically upload every image taken to this server. This way it is very easy for me to take a screenshot and then reference it here.
 

okee

New Member
Licensed User
Does that mean that there is no way of taking a screenshot from within an android phone ?
 

agraham

Expert
Licensed User
You can get a sort of screenshot with the Reflection library, but only from within the displayed Basic4android Activity
B4X:
Sub Btn1_Click
   Dim Obj1, Obj2 As Reflector
   Dim bmp As Bitmap
   Dim c As Canvas
   Obj1.Target = Obj1.GetActivityBA
   Obj1.Target = Obj1.GetField("vg")
   bmp.InitializeMutable(Activity.Width, Activity.Height)
   c.Initialize2(bmp)
   Dim args(1) As Object
   Dim types(1) As String
   Obj2.Target = c
   Obj2.Target = Obj2.GetField("canvas")
   args(0) = Obj2.Target
   types(0) = "android.graphics.Canvas"
   Obj1.RunMethod4("draw", args, types) 
   Dim Out As OutputStream
   Out = File.OpenOutput(File.DirRootExternal, "Test.png", False)
   bmp.WriteToStream(out, 100, "PNG")
   Out.Close
End Sub
 

moster67

Expert
Licensed User
Tried it and it worked nicely. I am sure that code-snippet can become handy sooner or later.

Thanks! :sign0142:

You can get a sort of screenshot with the Reflection library, but only from within the displayed Basic4android Activity
 

francoisg

Active Member
Licensed User
Nice!
Also see the MyPhoneExplorer utility (phone management app) - search for it using google - it has the ability to show screenshots (even automatically updated) - you can basically see the live android screen on your windows desktop (no root required!)
It is freeware but you can donate to the author if you like his work (which I obviously do ;-)

Would really like to know how he did it!
 

agraham

Expert
Licensed User
Would really like to know how he did it!
As the USB connection needs USB debugging enabled on the phone and the adb driver installed on the PC it looks like he is using the connection to the adb daemon on the phone in the same way as ddms can get a screenshot from a non-rooted phone.
 

Mahares

Well Known Member
Licensed User
1. To see screenshots of your device, when launched, MyPhoneExplorer will display a horizontal bar menu: 'File', View', 'Extra'. (With phone connected to PC).
2. Select 'Extra'
3. Select 'Phone Keypad'. You should see your device screen on the PC monitor.
4. Click 'Automatic refresh' to display the device screen as it changes.
It works well. I wish it had a feature that allows you to record the screenshots in the background to a file as you pan your application.
 

alfcen

Well-Known Member
Licensed User
Press the Home key and the power switch simultaneously to save the screen to SD.
Requires Android 2.2 and higher. Not sure whether this works with all phone devices.
 

BarrySumpter

Active Member
Licensed User
1. To see screenshots of your device, when launched, MyPhoneExplorer will display a horizontal bar menu: 'File', View', 'Extra'. (With phone connected to PC).
2. Select 'Extra'
3. Select 'Phone Keypad'. You should see your device screen on the PC monitor.
4. Click 'Automatic refresh' to display the device screen as it changes.
It works well. I wish it had a feature that allows you to record the screenshots in the background to a file as you pan your application.

FJ Software :: Thema anzeigen - Howto and FAQ: Use Android Phones with MyPhoneExplorer
 

madSac

Active Member
Licensed User
You can get a sort of screenshot with the Reflection library, but only from within the displayed Basic4android Activity
B4X:
Sub Btn1_Click
   Dim Obj1, Obj2 As Reflector
   Dim bmp As Bitmap
   Dim c As Canvas
   Obj1.Target = Obj1.GetActivityBA
   Obj1.Target = Obj1.GetField("vg")
   bmp.InitializeMutable(Activity.Width, Activity.Height)
   c.Initialize2(bmp)
   Dim args(1) As Object
   Dim types(1) As String
   Obj2.Target = c
   Obj2.Target = Obj2.GetField("canvas")
   args(0) = Obj2.Target
   types(0) = "android.graphics.Canvas"
   Obj1.RunMethod4("draw", args, types) 
   Dim Out As OutputStream
   Out = File.OpenOutput(File.DirRootExternal, "Test.png", False)
   bmp.WriteToStream(out, 100, "PNG")
   Out.Close
End Sub
I am getting following error
B4X:
** Activity (main) Resume **


** Activity (main) Create, isFirst = true **


main_activity_create (java line: 302)


java.lang.NoSuchFieldError: anywheresoftware.b4a.BA.activityBA


   at anywheresoftware.b4a.agraham.reflection.Reflection.GetActivityBA(Reflection.java:651)
   at madsacsoft.maddev.main._activity_create(main.java:302)
   at java.lang.reflect.Method.invokeNative(Native Method)
   ......
 

madSac

Active Member
Licensed User
Update your Reflection library to the latest version.
Oh.I updated it
I tried to capture screen shot using service.It gave me error.But when I use it in activity it works fine.this restrict me to my application only.Is there any method by which I can get screenshot using service ?

root access (rooting) is can also be provided if needed
 
Top