diff --git a/doc/source/buildoptions.rst b/doc/source/buildoptions.rst
index 19360ff2fa..ae7241eb65 100644
--- a/doc/source/buildoptions.rst
+++ b/doc/source/buildoptions.rst
@@ -86,6 +86,8 @@ options (this list may not be exhaustive):
include multiple jar files, pass this argument multiple times.
- ``--intent-filters``: A file path containing intent filter xml to be
included in AndroidManifest.xml.
+- ``--content-providers``: A file path containing provider xml to be
+ included in AndroidManifest.xml.
- ``--service``: A service name and the Python script it should
run. See :ref:`arbitrary_scripts_services`.
- ``--add-source``: Add a source directory to the app's Java code.
diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py
index 8d3bee6ea6..28c5483621 100644
--- a/pythonforandroid/bootstraps/common/build/build.py
+++ b/pythonforandroid/bootstraps/common/build/build.py
@@ -372,6 +372,10 @@ def make_package(args):
with open(args.intent_filters) as fd:
args.intent_filters = fd.read()
+ if args.content_providers:
+ with open(args.content_providers) as f:
+ args.content_providers = f.read()
+
if not args.add_activity:
args.add_activity = []
@@ -507,6 +511,14 @@ def make_package(args):
join(res_dir, 'values/strings.xml'),
**render_args)
+ # extra xml resources
+ if args.add_xml_resource:
+ xml_res_dir = join(res_dir, 'xml')
+ if not exists(xml_res_dir):
+ os.mkdir(xml_res_dir)
+ for file_path in args.add_xml_resource:
+ shutil.copy(file_path, join(xml_res_dir, basename(file_path)))
+
if exists(join("templates", "custom_rules.tmpl.xml")):
render(
'custom_rules.tmpl.xml',
@@ -707,6 +719,16 @@ def parse_args_and_make_package(args=None):
'filename containing xml. The filename should be '
'located relative to the python-for-android '
'directory'))
+ ap.add_argument('--content-providers', dest='content_providers',
+ help=('Add providers xml rules to the '
+ 'AndroidManifest.xml file. The argument is a '
+ 'filename containing xml. The filename should be '
+ 'located relative to the python-for-android '
+ 'directory'))
+ ap.add_argument('--add-xml-resource', dest='add_xml_resource',
+ action='append',
+ help=('Copy this file to the src/main/res/xml '
+ 'subdirectory of the build.'))
ap.add_argument('--with-billing', dest='billing_pubkey',
help='If set, the billing service will be added (not implemented)')
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
diff --git a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml
index a37e720753..5a156d53db 100644
--- a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml
+++ b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml
@@ -129,9 +129,14 @@
{% endif %}
- {% for a in args.add_activity %}
-
- {% endfor %}
+
+ {% for a in args.add_activity %}
+
+ {% endfor %}
+
+ {%- if args.content_providers -%}
+ {{- args.content_providers -}}
+ {%- endif -%}
diff --git a/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml
index f3eb3befcf..6f2982bb4b 100644
--- a/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml
+++ b/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml
@@ -92,6 +92,10 @@
{% endif %}
+
+ {%- if args.content_providers -%}
+ {{- args.content_providers -}}
+ {%- endif -%}
diff --git a/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml
index 8b6b4ca923..ceef024234 100644
--- a/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml
+++ b/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml
@@ -94,6 +94,10 @@
{% endif %}
+
+ {%- if args.content_providers -%}
+ {{- args.content_providers -}}
+ {%- endif -%}