@@ -21,6 +21,10 @@ Pyjnius and Plyer are independent projects whose documentation is
2121linked above. See below for some simple introductory examples, and
2222explanation of how to include these modules in your APKs.
2323
24+ This page also documents the ``android `` module which you can include
25+ with p4a, but this is mostly replaced by Pyjnius and is not
26+ recommended for use in new applications.
27+
2428
2529Using Pyjnius
2630-------------
@@ -100,3 +104,46 @@ would achieve vibration as described in the Pyjnius section above::
100104 vibrate(10) # in Plyer, the argument is in seconds
101105
102106This is obviously *much * less verbose than with Pyjnius!
107+
108+
109+ Using ``android ``
110+ -----------------
111+
112+ This Cython module was used for Android API interaction with Kivy's old
113+ interface, but is now mostly replaced by Pyjnius.
114+
115+ The ``android `` Python module can be included by adding it to your
116+ requirements, e.g. :code: `--requirements=kivy,android `. It is not
117+ automatically included by Kivy unless you use the old (Pygame)
118+ bootstrap.
119+
120+ This module is not separately documented. You can read the source `on
121+ Github
122+ <https://github.com/kivy/python-for-android/tree/master/pythonforandroid/recipes/android/src/android> `__.
123+
124+ One useful facility of this module is to make
125+ :code: `webbrowser.open() ` work on Android. You can replicate this
126+ effect without using the android module via the following
127+ code::
128+
129+ from jnius import autoclass
130+
131+ def open_url(url):
132+ Intent = autoclass('android.content.Intent')
133+ Uri = autoclass('android.net.Uri')
134+ browserIntent = Intent()
135+ browserIntent.setAction(Intent.ACTION_VIEW)
136+ browserIntent.setData(Uri.parse(url))
137+ currentActivity = cast('android.app.Activity', mActivity)
138+ currentActivity.startActivity(browserIntent)
139+
140+ class AndroidBrowser(object):
141+ def open(self, url, new=0, autoraise=True):
142+ open_url(url)
143+ def open_new(self, url):
144+ open_url(url)
145+ def open_new_tab(self, url):
146+ open_url(url)
147+
148+ import webbrowser
149+ webbrowser.register('android', AndroidBrowser, None, -1)
0 commit comments