简体   繁体   English

如何在Android代码中启动uiautomator?

[英]How can i start the uiautomator in android code?

I want to start an uiautomatorTest program in android code. 我想在android代码中启动uiautomatorTest程序。 I use: 我用:

Runtime.getRuntime().exec("uiautomator runtest AutoRunner.jar -c com.Runner.AutoRunner");

I get the error: 我得到错误:

java.lang.SecurityException: You do not have android.permission.RETRIEVE_WINDOW_CONTENT required to call registerUiTestAutomationService from pid=7071, uid=10156

Can anyone tell me how to solve the problem? 谁能告诉我如何解决这个问题? thanks 谢谢

As the discussion It seems, this Permission is only granted to system apps And it seems you may have forgot to add the permission also, 正如讨论所示 ,此权限仅授予系统应用程序,而且您似乎也忘记添加该权限,

To add the permission : 要添加权限:

add this directly to your manifest 将此直接添加到您的清单

   <uses-permission android.permission.RETRIEVE_WINDOW_CONTENT />

OR Inside the service you want the operation to be done like 在服务内部,您希望像

    <service android:name=".MyAccessibilityService"
         android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
     <intent-filter>
         <action android:name="android.accessibilityservice.AccessibilityService" />
     </intent-filter>
     . . .
 </service>

Have a brief look at Doc 简要了解Doc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM