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: docs/source/android.rst
+33-35Lines changed: 33 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,11 @@
1
1
Python API
2
2
==========
3
3
4
-
Python for android project include a "android" python module. The module is
5
-
composed of multiple part, mostly done for a easier usage of Java API. The
6
-
module is not designed to wrap anything you want.
4
+
The Python for android project includes a Python module called "android". It
5
+
consists of multiple parts which are mostly there to facilitate the use of the Java API.
7
6
8
-
Most of the Java API is accessible with PyJNIus, and then. prefer to see if you
9
-
can use Java API directly first.
7
+
This module is not designed to be comprehensive. Most of the Java API is also accessible with PyJNIus,
8
+
so if you can't find what you need here you can try using the Java API directly instead.
10
9
11
10
12
11
Android (``android``)
@@ -17,18 +16,18 @@ Android (``android``)
17
16
.. function:: check_pause()
18
17
19
18
This should be called on a regular basis to check to see if Android
20
-
expects the game to pause. If it return true, the game should call
21
-
:func:`android.wait_for_resume()`, after persisting its state as necessary.
19
+
expects the application to pause. If it returns true, the app should call
20
+
:func:`android.wait_for_resume()`, after storing its state as necessary.
22
21
23
22
.. function:: wait_for_resume()
24
23
25
-
This function should be called after :func:`android.check_pause()` returns
24
+
This function should be called after :func:`android.check_pause()` and returns
26
25
true. It does not return until Android has resumed from the pause. While in
27
-
this function, Android may kill a game without further notice.
26
+
this function, Android may kill the app without further notice.
28
27
29
28
.. function:: map_key(keycode, keysym)
30
29
31
-
This maps between an android keycode and a python keysym. The android
30
+
This maps an android keycode to a python keysym. The android
32
31
keycodes are available as constants in the android module.
33
32
34
33
@@ -37,7 +36,7 @@ Activity (``android.activity``)
37
36
38
37
.. module:: android.activity
39
38
40
-
The default PythonActivity have 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)>`_.
39
+
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)>`_.
41
40
42
41
.. function:: bind(eventname=callback, ...)
43
42
@@ -51,8 +50,7 @@ The default PythonActivity have a observer pattern for `onActivityResult <http:/
51
50
52
51
Example::
53
52
54
-
# this example is a snippet from an NFC p2p app, and are located into a
55
-
# kivy App class implementation
53
+
# This example is a snippet from an NFC p2p app implemented with Kivy.
56
54
57
55
from android import activity
58
56
@@ -81,9 +79,9 @@ Billing (``android.billing``)
81
79
82
80
.. module:: android.billing
83
81
84
-
This billing module give an access to the `In-App Billing <http://developer.android.com/guide/google/play/billing/billing_overview.html>`_:
82
+
This billing module gives an access to the `In-App Billing <http://developer.android.com/guide/google/play/billing/billing_overview.html>`_:
85
83
86
-
#. `Setup a test accounts<http://developer.android.com/guide/google/play/billing/billing_admin.html#billing-testing-setup>`_, and get your Public Key
84
+
#. `Setup a test account<http://developer.android.com/guide/google/play/billing/billing_admin.html#billing-testing-setup>`_, and get your Public Key
87
85
#. Export your public key::
88
86
89
87
export BILLING_PUBKEY="Your public key here"
@@ -104,18 +102,18 @@ This billing module give an access to the `In-App Billing <http://developer.andr
104
102
# Start the billing service, and attach our callback
105
103
self.service = BillingService(billing_callback)
106
104
107
-
# Start a clock to check billing service message every seconds
105
+
# Start a clock to check billing service message every second
108
106
Clock.schedule_interval(self.service.check, 1)
109
107
110
108
def billing_callback(self, action, *largs):
111
-
'''Callback that will receive all the event from the Billing service
109
+
'''Callback that will receive all the events from the Billing service
112
110
'''
113
111
if action == BillingService.BILLING_ACTION_ITEMSCHANGED:
114
112
items = largs[0]
115
113
if 'org.kivy.gopremium' in items:
116
-
print 'Congratulation, you have a premium acess'
114
+
print "Congratulations, you have a premium acess"
117
115
else:
118
-
print 'Unfortunately, you dont have premium access'
116
+
print "Unfortunately, you don't have premium access"
119
117
120
118
def buy(self, sku):
121
119
# Method to buy something.
@@ -125,7 +123,7 @@ This billing module give an access to the `In-App Billing <http://developer.andr
125
123
# Return all the items purchased
126
124
return self.service.get_purchased_items()
127
125
128
-
#. To initiate a in-app purchase, just call the buy method::
126
+
#. To initiate an in-app purchase, just call the buy() method::
129
127
130
128
# Note: start the service at the start, and never twice!
131
129
bs = MyBillingService()
@@ -136,7 +134,7 @@ This billing module give an access to the `In-App Billing <http://developer.andr
136
134
print bs.get_purchased_items()
137
135
{'org.kivy.gopremium': {'qt: 1}}
138
136
139
-
#. You'll receive all the notification about the billing process in the callback.
137
+
#. You'll receive all the notifications about the billing process in the callback.
140
138
141
139
#. Last step, create your application with `--with-billing $BILLING_PUBKEY`::
142
140
@@ -157,8 +155,8 @@ or categories filters.
157
155
158
156
.. warning::
159
157
160
-
The callback will be called in another thread than the main thread. Be
161
-
careful to not access to OpenGL or something like that.
158
+
The callback will be called in another thread than the main thread. In
159
+
that thread, be careful not to access OpenGL or something like that.
0 commit comments