Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does Pyjnius use instance methods as static methods? #488

Closed
pakal opened this issue Feb 21, 2020 · 3 comments
Closed

How does Pyjnius use instance methods as static methods? #488

pakal opened this issue Feb 21, 2020 · 3 comments
Labels

Comments

@pakal
Copy link
Contributor

pakal commented Feb 21, 2020

Python-for-android and other packages use these types of statements, but I can't understand how they can work, since they loads CLASSES (ehere PythonActivity), and call normal, non-static METHODS on them.

How can it be possible? These methods use "this" in their implementation, is there a magic lookup of mActivity or mService static instances on these classes to do the work? If so I'd gladly document it.

        python_activity = autoclass('org.kivy.android.PythonActivity')
        python_activity.checkCurrentPermission(permission + "")
@tshirtman
Copy link
Member

https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/recipes/android/src/android/activity.py#L4
this one uses mActivity, do you have an exmaple of where we do this call on the class?

@pakal
Copy link
Contributor Author

pakal commented Feb 22, 2020

Yes there are multiple similar calls in python-for-android, eg. https://github.com/kivy/python-for-android/blob/8740267d82fc3797a56ee355c9e69f4f30b35a84/pythonforandroid/recipes/android/src/android/permissions.py#L577

I tested it in my own app, the method call works whereas there is no instance explicitly involved.

@github-actions
Copy link

👋 We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project.
Let us know if this comment was made in error, and we'll be happy to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants