2017-07-18 80 views
0

我有一個按鈕,啓動一個新的活動。 AndroidViewClient中是否有API來獲取當前活動的包和名稱?類似:獲取當前的活動名稱和包?

view.click() # starts a new activity 
ViewClient.sleep(5) # wait for it to start 
activityName = magic.getActivityName() 
activityPackage = magic.getActivityPackage() 

由於

回答

0

這將打印例如在頂和包

#! /usr/bin/env python 
# -*- coding: utf-8 -*- 
''' 
Copyright (C) 2013-2017 Diego Torres Milano 
Created on 2017-07-18 by Culebra v13.4.0 
         __ __ __ __ 
        /\/\/\/\ 
____________________/ __\/ __\/ __\/ __\_____________________________ 
___________________/ /__/ /__/ /__/ /________________________________ 
        |/\ /\ /\ /\ \___ 
        |/ \_/ \_/ \_/ \ o \ 
              \_____/--< 
@author: Diego Torres Milano 
@author: Jennifer E. Swofford (ascii art snake) 
''' 


import re 
import sys 
import os 


from com.dtmilano.android.viewclient import ViewClient 

TAG = 'CULEBRA' 

_s = 5 
_v = '--verbose' in sys.argv 


kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False} 
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1) 
print device.getTopActivityName() 

com.android.calculator2/.Calculator