am start -a ACTIVITY from uiautomator code

大兔子大兔子 提交于 2019-12-23 07:00:19

问题


I am trying to launch Settings app from am start -a ACTIVITY from uiautomator code, in this way: am start -n com.android.settings/.Settings

But the problem is, the settings activity in one samsung device is /.Settings & in another device is /.SettingsTabActivity.

So, how can write the code that should launch Settings app in both the phones? (means how to handle both activities /.Settings & /.SettingsTabActivity)


回答1:


Get the device name from getprop ro.build.product and store to a string devname, Accordingly use the activity name.

if (devname.contains("samsung"))
    Runtime.getRuntime()
    .exec("am start -n com.android.settings/.Settings");
else
    Runtime.getRuntime()
   .exec("am start -n com.android.settings/.Settings$WifiSettingsActivity");



回答2:


If you just want to start the main settings app then just use - am start com.android.settings this starts the package's main activity so should solve your problem.



来源:https://stackoverflow.com/questions/22008706/am-start-a-activity-from-uiautomator-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!