|
| 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 | + |
0 commit comments