Android Integration test application permissions

馋奶兔 提交于 2019-12-24 10:45:31

问题


I'm looking a way to get current device's serial number in my integration tests.

Now, when calling

TelephonyManager manager = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = manager.getDeviceId();

in my test method, I get java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10227 nor current process has android.permission.READ_PHONE_STATE.

I added <uses-permission android:name="android.permission.READ_PHONE_STATE"/> in my test project AndroidManifest.xml, but that did not helped.


回答1:


You should check whether Read_Phone_State permission is added in your application's AndroidManifest.xml or not.

like This::

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>  

If it is not there please add it, because your testcase can not have more privilege than your application.



来源:https://stackoverflow.com/questions/18035785/android-integration-test-application-permissions

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