android - Getting permission denial while reading content provider using a custom permission -


i have 2 different apps. app defines custom permission , content provider needs defined custom permission. app b uses permission , tries access content provider of app a. however, following error:

java.lang.securityexception: permission denial: reading com.casimirlab.simpledeadlines.provider.deadlineprovider uri content://com.casimirlab.simpledeadlines.provider/deadlines pid=17350, uid=10070 requires com.casimirlab.simpledeadlines.read_deadline_database, or granturipermission() 

androidmanifest.xml app a:

<permission android:name="com.casimirlab.simpledeadlines.read_deadline_database" android:protectionlevel="normal"> </permission>  <uses-permission android:name="com.casimirlab.simpledeadlines.read_deadline_database" />  ...  <provider         android:name=".provider.deadlineprovider"         android:authorities="com.casimirlab.simpledeadlines.provider"         android:readpermission="com.casimirlab.simpledeadlines.read_deadline_database"         android:exported="true"         android:granturipermissions="true" /> 

androidmanifest.xml app b:

<uses-permission android:name="com.casimirlab.simpledeadlines.read_deadline_database" /> 

query code in app b:

uri uri = uri.parse("content://com.casimirlab.simpledeadlines.provider/deadlines"); contentresolver cr = getcontentresolver(); cursor cursor = cr.query(uri, null, null, null, null); 

i using following versions both apps.

compilesdkversion 23 buildtoolsversion '25.0.0'  minsdkversion 10 targetsdkversion 23 

i know order of app installations. first install app , app b.

i've read other related questions solutions didn't me.

rework permission declaration, xml case sensitive:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"           package="com.casimirlab.simpledeadlines">      <permission android:name="com.casimirlab.simpledeadlines.read_deadline_database"                 android:protectionlevel="normal" />     ... </manifest> 

you might consider declaring protection level "dangerous", requiring user confirmation allow (and on newer version of android requiring newer permission handling.)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -