Comments (3)
Yes, that last sentence "You must.." says, perhaps not in the clearest way possible, what you did.
There is an example of this 3 subsections below https://github.com/Android-for-Python/Android-for-Python-Users#java-listener-class , at a minimum adding a reference would be a good idea.
That section in turn references a full BroadcastReceiver (!) example nearby.
EDIT: Users seem to make a mental distinction between implementing in Python and implementing in Java - using Pyjnius is viewed as implementing in Python. Implementing in Java is viewed as a different task - possibly unfamiliar language and buildozer options. So the intent here was dismiss that second task and deal with it separately. Writing this document I have learned to never underestimate the inexperience of the users.
from android-for-python-users.
-
I make a distinction between writing code that uses Python syntax and code that uses Java syntax (e.g. "public interface"). If you are suggesting that using pyjnius's autoclass and decorators is considered "writing the implementation in Java", then I think we need to edit the document to make the definitions clearer.
-
About 3 years ago, I implemented a number of Listeners.
I did it differently to you. (I assume I pinched my approach from somewhere else online.) You have what is clearly Java code. I don't. I have some pyjnius references:
class OnAudioFocusChangeListener(PythonJavaClass):
# https://developer.android.com/reference/android/media/
# AudioManager.OnAudioFocusChangeListener
__javainterfaces__ = ("android/media/AudioManager$OnAudioFocusChangeListener",)
def __init__(self, callback):
super().__init__()
self.callback = callback
@java_method("(I)V")
def onAudioFocusChange(self, focusChange):
self.callback(focusChange)
This seems more straightforward than your approach (especially because I don't need to relearn Java syntax after successfully avoiding it since last century), but I know I am naïve in this domain, so I wonder if I am missing something!
- After implementing several listener interfaces, I spent hours and hours on dealing with BroadcastReceiver, because it looks and acts like a Listener class, but for some reason it wasn't defined in Android like all the other Listener classes. My first attempts to treat it the same failed. I needed to take a novel implementation approach.
So, when you point me to the Listener implementation, I go "No! No! This is different. For reasons I don't remember well."
Aside: I have only just clicked that it is the same class as in p4a's undocumented android
package, and I should have used that instead. I am a bit mad about that.
from android-for-python-users.
There is more than one way to skin a cat. The 'best' way is often subjective.
from android-for-python-users.
Related Issues (8)
- request few topics HOT 1
- empty HOT 1
- What are the requirements need to be mentioned in buildozer for firebase-admin Python? HOT 2
- Android-for-Python
- File-path, POSIX file processing _is_ still possible on Android HOT 5
- EM_X86_64 (62) instead of EM_AARCH64 (183) HOT 1
- Example of Pyjnius performance improvement HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-for-python-users.