mirror of https://github.com/kivy/pyjnius.git
Update README.md
This commit is contained in:
parent
a2dd51da1c
commit
30b083b362
28
README.md
28
README.md
|
@ -69,4 +69,32 @@ I/python ( 5983): [0.26815059781074524, 9.3469638824462891, 2.3463177680969238]
|
|||
I/python ( 5983): [-0.1149216815829277, 9.3852710723876953, 2.31758713722229]
|
||||
I/python ( 5983): [-0.038307227194309235, 9.41400146484375, 1.8674772977828979]
|
||||
I/python ( 5983): [0.13407529890537262, 9.4235782623291016, 2.2026655673980713]
|
||||
```
|
||||
|
||||
Advanced example
|
||||
----------------
|
||||
|
||||
When you use autoclass, it will discover all the methods and fields within the object, and resolve it.
|
||||
It's better to declare and use only what you need (for the moment).
|
||||
The previous example can be done manually:
|
||||
|
||||
```python
|
||||
from time import sleep
|
||||
from java import MetaJavaClass, JavaClass, JavaMethod, JavaStaticMethod
|
||||
|
||||
class Hardware(JavaClass):
|
||||
__metaclass__ = MetaJavaClass
|
||||
__javaclass__ = 'org/renpy/android/Hardware'
|
||||
vibrate = JavaStaticMethod('(D)V')
|
||||
accelerometerEnable = JavaStaticMethod('(Z)V')
|
||||
accelerometerReading = JavaStaticMethod('()[F')
|
||||
getDPI = JavaStaticMethod('()I')
|
||||
|
||||
# use that new class!
|
||||
print 'DPI is', Hardware.getDPI()
|
||||
|
||||
Hardware.accelerometerEnable()
|
||||
for x in xrange(20):
|
||||
print Hardware.accelerometerReading()
|
||||
sleep(.1)
|
||||
```
|
Loading…
Reference in New Issue