passing int argument to android fails with No methods matching your arguments

209 views
Skip to first unread message

Petr Vanek

unread,
Jan 22, 2013, 3:13:57 PM1/22/13
to pyjni...@googlegroups.com
Good evening,

as reported on irc, passing int values as arguments to an Intent fails with No methods matching your arguments.
Passing strings generally works ok. Here is an example code:

from jnius import cast
from jnius import autoclass
PythonActivity = autoclass('org.renpy.android.PythonActivity')
Intent = autoclass('android.content.Intent')
intent = Intent()
intent.setAction(Intent.ACTION_EDIT)
intent.setType('vnd.android.cursor.item/event')
intent.putExtra("eventLocation","Place")
intent.putExtra("description","desc")
intent.putExtra("beginTime", 1198628984102);
currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
currentActivity.startActivity(intent)


failing with:
"jnius.jnius.JavaException: No methods matching your arguments"


It seems that the issue is somewhere in jnius_export_class.pxi:
def __call__(self, *args):
...
if not scores:
            raise JavaException('No methods matching your arguments')
 
but this goes way above my head... shell i file a bugreport?

Is there any way for me to work around this, before it gets found?

thank you

Petr




Petr Vanek

unread,
Feb 10, 2013, 3:40:13 PM2/10/13
to pyjni...@googlegroups.com
Hi there ,

is this a bug or just me, as nobody commented on this?
Can anybody just pass ints from python to java with pjnius?

thank you

Petr

Axel Bemetz

unread,
May 16, 2014, 10:15:28 AM5/16/14
to pyjni...@googlegroups.com
Hello,
it seems to be me that I have the same problem. I can set an alarm properly, but setting the hour and minutes does not work. Setting the string EXTRA_MESSAGE works all right.

Intent = autoclass('android.content.Intent')
PythonActivity = autoclass('org.renpy.android.PythonActivity')
AlarmClock = autoclass('android.provider.AlarmClock')

intent = Intent(AlarmClock.ACTION_SET_ALARM)
intent.putExtra(AlarmClock.EXTRA_HOUR, 11)
intent.putExtra(AlarmClock.
EXTRA_MINUTES, 2)
intent.putExtra(AlarmClock.EXTRA_MESSAGE,"My alarm")
PythonActivity.mActivity.startActivity(intent)

But I do not see any error messages. The alarm is set on 0:00. The statements to set EXTRA_HOUR and EXTRA_MINUTES do not have any impact.
Regards
Axel


Mathieu Virbel

unread,
May 16, 2014, 11:35:19 AM5/16/14
to pyjni...@googlegroups.com
Hi,

Did you add the SET_ALARM permissions?

Mathieu
> --
> You received this message because you are subscribed to the Google
> Groups "PyJNIus development ML" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pyjnius-dev...@googlegroups.com
> <mailto:pyjnius-dev...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Axel Bemetz

unread,
May 19, 2014, 2:58:40 AM5/19/14
to pyjni...@googlegroups.com
Hi Mathieu,
I have added "--permission SET_ALARM". But it did not make any difference and during installation I was not asked to accept a new permission. Maybe it is the wrong keyword or the keyword is not passed through.

Because I am able to set the message text, I believe the permission is not the problem.
Regards
Axel

AxelB

unread,
May 28, 2014, 10:15:14 AM5/28/14
to pyjni...@googlegroups.com
Hi Mathieu,
I get the following two errors:

W/Bundle  (14844): Key android.intent.extra.alarm.HOUR expected Integer but value was a java.lang.Short.  The default value 0 was returned.
W/Bundle  (14844): Attempt to cast generated internal exception:
W/Bundle  (14844): java.lang.ClassCastException: java.lang.Short cannot be cast to java.lang.Integer
W/Bundle  (14844):   at android.os.Bundle.getInt(Bundle.java:940)
W/Bundle  (14844):   at android.os.Bundle.getInt(Bundle.java:923)
W/Bundle  (14844):   at ch.bitspin.timely.alarm.IntentAlarmSetter.onCreate(SourceFile:40)
W/Bundle  (14844):   at ch.bitspin.timely.alarm.IntentAlarmSetter_.onCreate(SourceFile:29)
W/Bundle  (14844):   at android.app.Activity.performCreate(Activity.java:5206)
W/Bundle  (14844):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
W/Bundle  (14844):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
W/Bundle  (14844):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
W/Bundle  (14844):   at android.app.ActivityThread.access$700(ActivityThread.java:140)
W/Bundle  (14844):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
W/Bundle  (14844):   at android.os.Handler.dispatchMessage(Handler.java:99)
W/Bundle  (14844):   at android.os.Looper.loop(Looper.java:137)
W/Bundle  (14844):   at android.app.ActivityThread.main(ActivityThread.java:4921)
W/Bundle  (14844):   at java.lang.reflect.Method.invokeNative(Native Method)
W/Bundle  (14844):   at java.lang.reflect.Method.invoke(Method.java:511)
W/Bundle  (14844):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
W/Bundle  (14844):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
W/Bundle  (14844):   at dalvik.system.NativeStart.main(Native Method)
W/Bundle  (14844): Key android.intent.extra.alarm.MINUTES expected Integer but value was a java.lang.Short.  The default value 0 was returned.
W/Bundle  (14844): Attempt to cast generated internal exception:
W/Bundle  (14844): java.lang.ClassCastException: java.lang.Short cannot be cast to java.lang.Integer
W/Bundle  (14844):   at android.os.Bundle.getInt(Bundle.java:940)
W/Bundle  (14844):   at ch.bitspin.timely.alarm.IntentAlarmSetter.onCreate(SourceFile:41)
W/Bundle  (14844):   at ch.bitspin.timely.alarm.IntentAlarmSetter_.onCreate(SourceFile:29)
W/Bundle  (14844):   at android.app.Activity.performCreate(Activity.java:5206)
W/Bundle  (14844):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
W/Bundle  (14844):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
W/Bundle  (14844):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
W/Bundle  (14844):   at android.app.ActivityThread.access$700(ActivityThread.java:140)
W/Bundle  (14844):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
W/Bundle  (14844):   at android.os.Handler.dispatchMessage(Handler.java:99)
W/Bundle  (14844):   at android.os.Looper.loop(Looper.java:137)
W/Bundle  (14844):   at android.app.ActivityThread.main(ActivityThread.java:4921)
W/Bundle  (14844):   at java.lang.reflect.Method.invokeNative(Native Method)
W/Bundle  (14844):   at java.lang.reflect.Method.invoke(Method.java:511)
W/Bundle  (14844):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
W/Bundle  (14844):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
W/Bundle  (14844):   at dalvik.system.NativeStart.main(Native Method)


Is there a way to convert from Short to Integer? I tried to autoclass Integer, but I got the same error.
Thanks in advance
Axel
Reply all
Reply to author
Forward
0 new messages