0

Android 6에서 안드로이드 애플리케이션을 개발 중이고 서비스의 애플리케이션이 장치 ID (getDeviceId)를 가져와야합니다. 나는 매니페스트 파일에 android.permission.READ_PHONE_STATE를 설정하지만, 런타임에이 오류를 가지고 :안드로이드 6에서 사용자 10632도 현재 프로세스도 안드로이드 6에서 android.permission.READ_PHONE_STATE 오류가 발생했습니다.

neither user 10632 nor current process has android.permission.READ_PHONE_STATE. java.lang.SecurityException:getDeviceId need android.permission.Read_Phone_state 

나는 adb install myapk.apk를 사용하여 내 APK 파일을 설치하고 나는 응용 프로그램에 필요한 모든 권한은 설치시 부여되는 것을 가정합니다.

+0

https://developer.android.com/training/permissions/requesting.html의 – X3Btel

+2

가능한 복제 [방법 안드로이드 6에서 사용자 권한을 요청] (http://stackoverflow.com/questions/35091327/how-to-ask-for-user-permissions-in-android-6) – X3Btel

답변

1

또한 런타임에 권한을 요청해야합니다.

int permissionCheck = ContextCompat.checkSelfPermission(thisActivity, 
    Manifest.permission.READ_PHONE_STATE); 

If the app has the permission, the method returns PackageManager.PERMISSION_GRANTED, and the app can proceed with the operation. If the app does not have the permission, the method returns PERMISSION_DENIED, and the app has to explicitly ask the user for permission.

당신이 그것을 얻을 해달라고하면, 당신은 그것을 요청해야

ActivityCompat.requestPermissions(thisActivity, 
       new String[]{Manifest.permission.READ_PHONE_STATE}, 
       MY_PERMISSIONS_REQUEST_READ_PHONE_STATE); 
+0

내가 사용자에게 묻지 않는 방법이 있습니까 런타임시 사용 권한에 대해? – Stateless