Closed mowshon closed 2 years ago
PS: writeImageToFile
is not what I need, it will save with all trash like buttons and text, I need clean image.
@dtmilano can you help me with an advice?
First, you can try
$ dump --save-view-screenshots=/tmp
to see if there is an image that suits your needs.
@dtmilano thank you for fast reply!
But how can I extract and save image from android.widget.ImageView object with Python? I'm sure that this object has an image.
from com.dtmilano.android.viewclient import ViewClient
phone = ViewClient(*ViewClient.connectToDeviceOrExit())
phone.traverse()
Result:
android.widget.FrameLayout
android.widget.ImageView com.viber.voip:id/photo
android.widget.ImageButton
android.widget.TextView com.viber.voip:id/menu_favorite
android.widget.TextView com.viber.voip:id/menu_contact_edit
android.widget.ImageView
android.widget.TextView com.viber.voip:id/toolbar_custom_title +1000000000
android.widget.TextView com.viber.voip:id/toolbar_custom_subtitle Last seen today at 09:47
androidx.recyclerview.widget.RecyclerView com.viber.voip:id/items
android.widget.Button com.viber.voip:id/left_button Free call
android.widget.Button com.viber.voip:id/right_button Free message
android.widget.FrameLayout com.viber.voip:id/contact_details_call_ways_item_container
android.widget.TextView com.viber.voip:id/contact_details_call_ways_item_description_container +1000000000
android.widget.FrameLayout com.viber.voip:id/contact_details_call_ways_item_container
android.widget.TextView com.viber.voip:id/contact_details_call_ways_item_description_container Free video call
android.widget.FrameLayout com.viber.voip:id/contact_details_call_ways_item_container
android.widget.TextView Viber Out call
android.widget.TextView Low-cost calling rates!
android.widget.FrameLayout com.viber.voip:id/contact_details_call_ways_item_container
android.widget.TextView Cellular call
android.widget.TextView Mobile carrier's rates apply
So, I want to extract photo from this widget, but how?
android.widget.ImageView com.viber.voip:id/photo
To obtain the image of any View, that is, it doesn't have to be an ImageView
, could be anything, you do:
vc.findViewByIdOrRaise("com.android.vending:id/mic_button").writeImageToFile('/tmp/mic.png')
If the Views are overlapping then this image will be delimited by the bounds of the View you are obtaining the image, and as you mentioned it contains parts of the other Views.
Hi!
This is my code:
I want to get
src
from viber user avatar. All viber avatar are cached in/sdcard/Android/data/com.viber.voip/files/User photos
but how can I get thesrc
directly fromandroid.widget.ImageView
?