Take Screenshot of Android screen and save to SD card

前端 未结 4 597
南旧
南旧 2021-01-16 09:00

There are a few questions here on SO about capturing screenshots of an android application. However, I haven\'t found a solid solution on how to take a screenshot programati

4条回答
  •  温柔的废话
    2021-01-16 09:14

    monkeyrunner tool can do the job for you with bit of adb command, [python script]

    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
    //waits for connection
    device = MonkeyRunner.waitForConnection()
    //take the current snapshot
    device.takeSnapshot()
    //stores the current snapshot in current dir in pc
    device.writeToFile('current.png')\
    //copy it to the sd card of device
    os.subprocess.call('adb push current.png /sdcard/android/com.test.myapp/current.png')
    

    Note: call this jython script file
    monkeyrunner.bat

提交回复
热议问题