Skip to content

Commit a73b507

Browse files
authored
Merge pull request kivy#1419 from kivy/doc_service_arg
doc: add instructions on accessing service argument
2 parents ce1ae44 + 8a254de commit a73b507

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

doc/source/services.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ python-for-android creates for each one, as follows::
7474
service.start(mActivity, argument)
7575

7676
Here, ``your.package.domain.package.name`` refers to the package identifier
77-
of your APK.
77+
of your APK.
7878

7979
If you are using buildozer, the identifier is set by the ``package.name``
8080
and ``package.domain`` values in your buildozer.spec file.
@@ -89,6 +89,15 @@ argument, but with the first letter upper case. You must also pass the
8989
``argument`` parameter even if (as here) it is an empty string. If you
9090
do pass it, the service can make use of this argument.
9191

92+
The service argument is made available to your service via the
93+
'PYTHON_SERVICE_ARGUMENT' environment variable. It is exposed as a simple
94+
string, so if you want to pass in multiple values, we would recommend using
95+
the json module to encode and decode mode complex data.
96+
::
97+
98+
from os import environ
99+
argument = environ.get('PYTHON_SERVICE_ARGUMENT', '')
100+
92101
Services support a range of options and interactions not yet
93102
documented here but all accessible via calling other methods of the
94103
``service`` reference.

0 commit comments

Comments
 (0)