2

com.example.library.http.RestService라는 서비스가 포함 된 com.example.library라는 라이브러리가 있습니다. 라이브러리의 매니페스트에는 다음 요소가 포함되어 있습니다.SecurityException : 허가없이 서비스 인 텐트를 시작할 수 없음

<uses-permission android:name="com.example.library.permission.REST_PERMISSION" /> 

<permission 
    android:name="com.example.library.permission.REST_PERMISSION" 
    android:protectionLevel="signature" /> 

<application ...> 
    <service 
     android:name="com.example.library.http.RestService" 
     android:enabled="true" 
     android:permission="com.example.library.permission.REST_PERMISSION" 
     android:exported="true" > 
     <intent-filter> 
      <action android:name="com.example.library.LAUNCH_REST_SERVICE" /> 
     </intent-filter> 
    </service> 
</application> 

com.example.testapp이라는 응용 프로그램에서 해당 라이브러리를 사용하고 있습니다. TestApp의 매니페스트는 위의 라이브러리와 정확히 동일한 요소를 반복합니다. 이것은 4.0.3을 실행하는 에뮬레이터와 4.2.2을 실행하는 nexus 4에서 작동하지만, 2.3.5을 실행하는 HTC Wildfire S에서이 장치를 사용하려고하면이 장치는 순간적으로 넘어갑니다

java.lang.SecurityException: Not allowed to start service Intent 
{ act=com.example.library.LAUNCH_REST_SERVICE pkg=com.example.testapp (has extras) } 
without permission com.example.library.permission.REST_PERMISSION 

나는 다음과 같은 코드를 사용하여 서비스를 시작 해요 : 다음을 제외하고는 서비스를 시작하려고

Intent intent = new Intent(); 
intent.setAction("com.example.library.LAUNCH_REST_SERVICE"); 
intent.setPackage("com.example.testapp"); 

[setting some extras] 

startService(intent); 

내가 도움을 웹을 수색했습니다, 그리고 모든 읽고 관련 스택 오버플로 질문을 찾을 수 있지만 그냥 내가 빠진 것을 찾을 수 없다.

+0

''과''요소의 순서를 바꾸어 사용하기 전에 권한을 정의 해보십시오. – CommonsWare

+0

@CommonsWare는 제안에 감사하지만 유감스럽게도 아무런 차이가 없습니다. – Niall

+0

앞서 언급 한 변경 사항을 적용한 후 두 앱을 완전히 제거한 다음 다시 설치하고 도움이되는지 확인하십시오. – CommonsWare

답변

0

그래서 2.2 및 2.3 에뮬레이터에서 작동 한 후 Wildfire S를 공장 초기화했습니다. 이제 정상적으로 작동합니다.

이 문제는 다음과 유사하다고 생각합니다. Intent custom permission not working - 내 앱 패키지의 이름을 변경하면 효과가 있었을 것입니다.

관련 문제