0

I have a button which launches a new Activity. Is there an API in AndroidViewClient to get the package and name of the current activity? Something like:

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

Thanks

user3203425
  • 2,919
  • 4
  • 29
  • 48

1 Answers1

0

This prints the top Activity and package

#! /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()

for example

com.android.calculator2/.Calculator
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134