问题
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