Android Question Take Screenshot when connected over WiFi

yo3ggx

Active Member
Licensed User
Longtime User
Hello,

I'm using the latest B4A 13.40. I can take screenshots from IDE when connected over USB, but I can't when connected over WiFi with adb connect.
Installing applications works over WiFi, only Take Screenshot doesn't. In fact returns the latest screenshot taken when connected over USB.
This is a normal behavior?
I'm not using B4A-Bridge. I must use WiFi connection because USB is used for some other USB devices.

Thank you.
 

teddybear

Well-Known Member
Licensed User
Hello,
This is a normal behavior?
Thank you.
This is a trivial bug. when wireless debugging, you must manually connect to your phone by ip and port.
Installing app, adb uses the IP and port, so it works. in fact taking Screenshot, it also works, you can find the b4a_screenshot.png on your phone.
It doesn't work is because adb didn't specify the IP and port when pulling files to the PC. perhaps Erel will fix it in the next version
You can use the command to manually get b4a_screenshot.png.
B4X:
adb -s YourPhoneIP:port -d pull /sdcard/b4a_screenshot.png
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
adb is already connected, so I can run directly:
adb pull /sdcard/b4a_screenshot.png:
no matter if I'm connected over USB or IP and it works. IP address is not required to run the command, so why is working over USB and not over IP?
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
I created a bat script that remotely take a screenshot from the android device when connected with adb over IP and save it locally on the PC. You can have multiple adb connections to several Android devices and one script for each connection. Adjust the local folder and the device IP address accordingly. Hope this functionality will be integrated in a future version of B4A.

B4X:
@echo off
setlocal enabledelayedexpansion

:: Get current timestamp in format YYYYMMDD_HHMMSS
for /f "tokens=2 delims==." %%I in ('"wmic os get localdatetime /value"') do set datetime=%%I
set timestamp=%datetime:~0,8%_%datetime:~8,6%

:: Define device IPs
set deviceA=192.168.75.231

:: Screenshot from Device A
adb -s %deviceA% shell screencap -p /sdcard/screenshot.png
adb -s %deviceA% pull /sdcard/screenshot.png "C:\Projects\Screenshots\a53_%timestamp%.png"
adb -s %deviceA% shell rm /sdcard/screenshot.png

endlocal
 
Upvote 0
Top