Skip to content

Commit 59040f6

Browse files
committed
add API for listening onActivityResult and onNewIntent event in Activity
1 parent 6d02b8c commit 59040f6

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../src/libs

docs/source/activity.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Python Activity
2+
===============
3+
4+
Our android activity is named `org.renpy.android.PythonActivity` for a normal
5+
application, and `org.renpy.android.PythonService` for a service.
6+
7+
Accessing to the Python Activity API
8+
------------------------------------
9+
10+
Instead of wrapping all the java part into python extension, we think it's less
11+
work for us and easy for you to directly use Pyjnius::
12+
13+
from jnius import autoclass
14+
PythonActivity = autoclass('org.renpy.android.PythonActivity')
15+
16+
You have the class object of our Python Activity, and can access to anything from the API. If you want the instance of it, use:
17+
18+
- :data:`PythonActivity.mActivity` if you are running an application
19+
- :data:`PythonService.mService` if you are running a service
20+
21+
22+
23+
`PythonActivity` API
24+
--------------------
25+
26+
.. class:: PythonActivity
27+
28+
.. data:: mInfo
29+
30+
Instance of an `ApplicationInfo
31+
<http://developer.android.com/reference/android/content/pm/ApplicationInfo.html>`_
32+
33+
.. data:: mActivity
34+
35+
Instance of :class:`PythonActivity`.
36+
37+
.. method:: registerNewIntentListener(NewIntentListener listener)
38+
39+
Register a new instance of :class:`NewIntentListener` to be called when `onNewIntent <http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)>`_ is called.
40+
41+
.. method:: unregisterNewIntentListener(NewIntentListener listener)
42+
43+
Unregister a previously registered listener from :meth:`registerNewIntentListener`
44+
45+
.. method:: registerActivityResultListener(ActivityResultListener listener)
46+
47+
Register a new instance of :class:`ActivityResultListener` to be called when `onActivityResult <http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)>`_ is called.
48+
49+
.. method:: unregisterActivityResultListener(ActivityResultListener listener)
50+
51+
Unregister a previously registered listener from :meth:`PythonActivity.registerActivityResultListener`
52+
53+
.. class:: NewIntentListener
54+
55+
Listener interface for onNewIntent. You need to implementing it, create
56+
an instance and use it with :meth:`registerNewIntentListener`.
57+
58+
.. method:: onNewIntent(Intent intent)
59+
60+
Method to implement
61+
62+
.. class:: ActivityResultListener
63+
64+
Listener interface for onActivityResult. You need to implementing it,
65+
create an instance and use it with :meth:`PythonActivity.registerActivityResultListener`.
66+
67+
.. method:: onActivityResult(int requestCode, int resultCode, Intent data)
68+
69+
Method to implement
70+

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ your application.
2424
customize.rst
2525
recipes.rst
2626
android.rst
27+
activity.rst
2728
related.rst
2829
extend.rst
2930
faq.rst

0 commit comments

Comments
 (0)