dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.61k stars 344 forks source link

device.getTopActivityName #276

Closed first932167 closed 2 years ago

first932167 commented 4 years ago
def getTopActivityNameAndPid(self):
    dat = self.shell('dumpsys activity top')
    lines = dat.splitlines()
    print('adbClient',1331,lines[1],lines[2],lines[3])
    activityRE = re.compile('\s*ACTIVITY ([A-Za-z0-9_.]+)/([A-Za-z0-9_.\$]+) \w+ pid=(\d+)')
    #print('adbClient',1331,activityRE)
    m = activityRE.search(lines[1])
    if m:
        return m.group(1), m.group(2), m.group(3)
    else:
        m = activityRE.search(lines[2])
        if m:
            return m.group(1), m.group(2), m.group(3)
        else:
            warnings.warn("NO MATCH:" + lines[1])
            return None
dtmilano commented 4 years ago

Not sure what you mean. Are you seeing something in the print line you added? Can you provide the output?