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