Requesting read permission from my own ContentProvider in another app

后端 未结 1 1588
闹比i
闹比i 2021-01-12 16:38

In one app, I have the following content provider declared in my AndroidManifest:

    

        
相关标签:
1条回答
  • 2021-01-12 16:51

    In the app defining your ContentProvider, did you also define the permission you are requiring/requesting(in your other app)? Like so (within the root <manifest/> tag):

    <permission android:name="com.example.permission.READ" />
    

    In general, you need to:

    1. define the permission in one of your apps' manifest files
    2. request the permission in any of your apps' manifest files, for apps that wish to get the permission
    3. require this permission in any component that you wish to guard with this permission, like Activities, Services, or ContentProviders (read, write, both, specific sub-URIs, etc)

    Edit: so just to be 100% clear, it is NOT enough to "implicitly" define a permission by requiring it in, say, your ContentProvider. You have to define it explicitly in your app's manifest file (within the <manifest/> tag).

    0 讨论(0)
提交回复
热议问题