xiaocong / android-uiautomator-server

MIT License
169 stars 103 forks source link

How can I want to get the activity name? #15

Closed min-qiu closed 6 years ago

min-qiu commented 8 years ago

I want to get the activity name ,how should I do?

hongbinbao commented 8 years ago

May be this is what you want. the method is not exposed in AutomatorServiceImpl


String getCurrentActivityName() This method is deprecated. The results returned should be considered unreliable


if you just want to write black-box testing. why not to inspect the UI element which contained in your activity?

there is a solution to know the name of the current activity on the screen

d.server.adb.cmd("shell dumpsys activity | grep mFocusedActivity").communicate() (' mFocusedActivity: ActivityRecord{12b1619 u0 com.tencent.mm/.ui.LauncherUI t1743}\r\n', '') d.server.adb.cmd("shell dumpsys activity | grep mFocusedActivity").communicate() (' mFocusedActivity: ActivityRecord{9ab2406 u0 com.tencent.mm/.plugin.brandservice.ui.BrandServiceIndexUI t1743}\r\n', '')

xudafeng commented 7 years ago

@hongbinbao @min-qiu 尝试使用 macaca

https://github.com/macacajs/macaca-android/commit/1a9e77d6e44005827eef4f8ed14ee125e47fd28a