실행하는 데 사용되는 응용 프로그램. 그러나 얼마 지나지 않아 작업이 중단되기 시작했습니다. 기기가 Android Nutella를 실행 중입니다. 아래는 LogCat입니다.보안 예외 : 권한 거부
java.lang.SecurityException: Permission Denial: reading com.google.android.music.store.ConfigContentProvider uri content://com.google.android.music.ConfigContent/one-key/2/ExplicitRestrictedByParentControl from pid=2500, uid=10373 requires the provider be exported, or grantUriPermission()
마지막 줄의 다음 코드 조각 (SongParser 메서드에 포함)에서 응용 프로그램이 충돌합니다.
String[] projection2 = {MediaStore.Audio.Media.ARTIST};
Uri songUri=null;
try {
songUri = Uri.parse("content://com.google.android.music.MusicContent/audio");
} catch (NullPointerException e){
e.printStackTrace();
}
if (songUri!=null) {
CursorLoader cl2 = new CursorLoader(context,
songUri, projection2, null, null, null);
cursor = cl2.loadInBackground();
런타임 권한 방법을 통해 권한을 요청한 후 다음 방법으로 Uri 권한을 부여합니다.
private void startService() {
//start intent to RssService for feedback
intent = new Intent(getActivity(), SongService.class);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
getContext().grantUriPermission("xxx.xxx.xxx.SongService",Uri.parse("content://com.google.android.music.MusicContent/audio"),Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(SongService.RECEIVER, resultReceiver);
getActivity().startService(intent);
}
여기서 SongService가 SongParser를 호출하는 곳입니다.
@Override
protected void onHandleIntent(Intent intent) {
List<String> eventItems= null;
if (haveNetworkConnection()) {
parser = new SongParser();
eventItems = parser.getAllArtists(getApplicationContext());
}
Bundle bundle = new Bundle();
bundle.putSerializable(ITEMS, (Serializable) eventItems);
ResultReceiver receiver = intent.getParcelableExtra(RECEIVER);
receiver.send(0, bundle);}}
또한 매니페스트에 사용 권한이 포함되어 있습니다. 다시 말하지만,이 예외는 겉으로보기에도 혼자서 발생했습니다.
<permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
나는 같은 문제에 봉착했습니다. 내 휴대 전화에서는 정상적으로 작동하지만 일부 사용자에게는 문제가있는 것으로 보입니다. Play 뮤직 버전 7.6.4620-1.P.3889101이 있습니까? – geecko
네, –
와 동일한 버전의 나는, SecurityException를 잡아이를 무시 내 앱에 대한 업데이트를 밀었다. 누군가 나에게 이메일을 보내서 그것이 고쳐 졌다고 말해 준다. 나는 무슨 일이 일어나고 있는지 잘 모르겠지만, 문제는 분명히 해결되었습니다. – geecko