You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/apis.rst
+156Lines changed: 156 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -143,6 +143,162 @@ With the webview bootstrap, pausing should work automatically.
143
143
Under SDL2, you can handle the `appropriate events <https://wiki.libsdl.org/SDL_EventType>`__ (see SDL_APP_WILLENTERBACKGROUND etc.).
144
144
145
145
146
+
Observing Activity result
147
+
~~~~~~~~~~~~~~~~~~~~~~~~~
148
+
149
+
.. module:: android.activity
150
+
151
+
The default PythonActivity has a observer pattern for `onActivityResult <http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)>`_ and `onNewIntent <http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)>`_.
152
+
153
+
.. function:: bind(eventname=callback, ...)
154
+
155
+
This allows you to bind a callback to an Android event:
156
+
- ``on_new_intent`` is the event associated to the onNewIntent java call
157
+
- ``on_activity_result`` is the event associated to the onActivityResult java call
158
+
159
+
.. warning::
160
+
161
+
This method is not thread-safe. Call it in the mainthread of your app. (tips: use kivy.clock.mainthread decorator)
162
+
163
+
.. function:: unbind(eventname=callback, ...)
164
+
165
+
Unregister a previously registered callback with :func:`bind`.
166
+
167
+
Example::
168
+
169
+
# This example is a snippet from an NFC p2p app implemented with Kivy.
170
+
171
+
from android import activity
172
+
173
+
def on_new_intent(self, intent):
174
+
if intent.getAction() != NfcAdapter.ACTION_NDEF_DISCOVERED:
0 commit comments