如何配置内容提供者监听请求

How to configure content provider to be listening to requests

如何配置自定义 android 内容提供程序以侦听对它的请求?对自定义内容提供程序进行查询时会发生什么?它是否调用包含自定义内容提供程序的应用程序来读取数据?自定义内容提供程序是否应 运行 在后台执行来自其他应用程序的请求?

这是对自定义内容提供商的查询:

 Uri uri = Uri.parse("content://com.example.provider/table1");
        ContentProviderClient contentResolver = getContentResolver().acquireContentProviderClient(uri);
        Cursor cursor = contentResolver.query(uri, projection, null, null, null);

How can I configure a custom android content provider to be listening to requests to it ?

the <provider> element for it.

Does it invoke the app containing custom content provider to read data ?

是的。

Does custom content provider should be running in background to fulfill requests made from another app?

没有。如果需要,将为应用程序创建一个进程。