第一次使用monkeyrunner,試圖打開app的activity。
<span style="font-size:18px;"><span style="font-family:Microsoft YaHei;font-size:12px;">from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
device=MonkeyRunner.waitForConnection(1,"96e8d650")
device.startActivity(component = "com.qq.xgdemo/.HelpActivity")</span></span>
可以打開MainActivity,試圖打開HelpActivity時不成功, 日誌提示:
ActivityManager Permission Denial: starting Intent { flg=0x10000000 cmp=com.qq.xgdemo/.HelpActivity } from null (pid=9117, uid=2000) not exported from uid 10164
在AndroidManifest.xml找到HelpActivity,添加android:exported="true"即可。
<span style="font-size:18px;"><span style="font-family:Microsoft YaHei;font-size:12px;"><activity
android:name="com.qq.xgdemo.HelpActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:exported="true"/></span></span>
android:exported
這個屬性用於指示該服務是否能夠被其他應用程序組件調用或跟它交互