Android清单XML提供程序标签. android:authorities

当我在清单XML文件中遇到此标记时,我正在浏览android-17的NotePad示例应用程序:

    <provider android:name="NotePadProvider"
        android:authorities="com.google.provider.NotePad"
        android:exported="false">
        <grant-uri-permission android:pathPattern=".*" />
    </provider>

我查了一下单位名称,然后看到com.google.provider.NotePad被列为提供商的授权之一.我假设NotePadProvider引用了NotePadProvider.java文件中定义的NotePadProvider类,但是我想问一问是否确实如此,以确保我走在正确的轨道上.

另外,我想知道com.google.provider.NotePad到底是什么,它的定义是什么,以及com.google.provider.NotePad的目的是什么,以及com.google.provider.NotePad是该网站的授权机构.提供商.

解决方法:

那是ContentProvider.

Content providers are one of the primary building blocks of Android
applications, providing content to applications. They encapsulate data
and provide it to applications through the single ContentResolver
interface. A content provider is only required if you need to share
data between multiple applications. For example, the contacts data is
used by multiple applications and must be stored in a content
provider. If you don’t need to share data amongst multiple
applications you can use a database directly via SQLiteDatabase.

实际上,com.google.provider.NotePad是实现ContentProvider的类.

<provider>开始:

android:authorities
A list of one or more URI authorities that
identify data offered by the content provider. Multiple authorities
are listed by separating their names with a semicolon. To avoid
conflicts, authority names should use a Java-style naming convention
(such as com.example.provider.cartoonprovider). Typically, it’s the
name of the ContentProvider subclass that implements the provider

上一篇:authority解读


下一篇:ant design pro v2 关于用户登录有多个权限的解决方法