pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

Exception on Implement OnCompletionListener

Open gonzafirewall opened this issue 8 years ago • 4 comments

Hi people i have this error sometimes when i implement the OnCompletionListener

I/python (16270): 2015-11-24 08:22:46-0600 [-] Traceback (most recent call last): I/python (16270): 2015-11-24 08:22:46-0600 [-] File "jnius_proxy.pxi", line 151, in jnius.jnius.invoke0 (jnius/jnius.c:25574) I/python (16270): 2015-11-24 08:22:46-0600 [-] File "jnius_proxy.pxi", line 121, in jnius.jnius.py_invoke0 (jnius/jnius.c:25206) I/python (16270): 2015-11-24 08:22:46-0600 [-] AttributeError: 'list' object has no attribute 'invoke' F/libc (16270): Fatal signal 11 (SIGSEGV), thread 16270 (r.vixcam:python)

This error not occur all the time, some times works well and sometimes make this exception, this is my onCompletionListener

class PythonOnComplete(PythonJavaClass):                                     
     __javainterfaces__ = ['android/media/MediaPlayer$OnCompletionListener']  
     def __init__(self, websocket, *args, **kwargs):                          
         self.ws = websocket                                                  
         super(PythonOnComplete, self).__init__(*args, **kwargs)              


     @java_method('(Landroid/media/MediaPlayer;)V')                           
     def onCompletion(self, mp):                                              
         del self.ws.last_song                                                
         print "[PYTHON_ON_COMPLETE]" +" termino el tema"   


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

gonzafirewall avatar Nov 24 '15 14:11 gonzafirewall

Any advice?

dushujun avatar Dec 12 '18 01:12 dushujun

I have the same ...

vesellov avatar Dec 06 '19 12:12 vesellov

Any advice, guys?

AndyRusso avatar Nov 01 '21 06:11 AndyRusso

Wrap your head around this. An overview of this approach is described here: https://github.com/Android-for-Python/Android-for-Python-Users#calling-python-from-java

Links to an example follow (it has 3 listeners, one of which is onCompletion):

Write the completion listener in Java, for example: https://github.com/Android-for-Python/Face-Detect-Example/blob/main/mlkit_src/org/kivy/mlkit/CompleteListener.java . Using the Callback wrapper described above ( for this example I used https://github.com/Android-for-Python/Face-Detect-Example/blob/main/mlkit_src/org/kivy/mlkit/CallbackWrapper.java ).

Those classes are then used in Python like this: https://github.com/Android-for-Python/Face-Detect-Example/blob/main/facedetect.py#L29-L30

https://github.com/Android-for-Python/Face-Detect-Example/blob/main/facedetect.py#L33-L49

https://github.com/Android-for-Python/Face-Detect-Example/blob/main/facedetect.py#L63-L66

https://github.com/Android-for-Python/Face-Detect-Example/blob/main/facedetect.py#L93

A Python method is thus called from a Java onCompletionListener.

RobertFlatt avatar Nov 02 '21 23:11 RobertFlatt

👋 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.

github-actions[bot] avatar Oct 28 '23 01:10 github-actions[bot]