pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

I can't import caste

Open Jacques-Joao opened this issue 4 years ago • 1 comments

I'm new to programming and this is my first time using jnius.

I intend to create an android application that makes calls to different numbers, so I decided to use jnius and use the autoclass and cast functions, making an optimized import, I managed to import the autoclass but not cast.

My code is supposed to look like this:

from jnius import autoclass
from jnius import cast

Intent = autoclass('android.content.Intent')
Uri = autoclass('android.net.Uri')
PythonActivity = autoclass('org.renpy.android.PythonActivity')
intent = Intent(Intent.ACTION_CALL)
intent.setData(Uri.parse("tel:" + num))
currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
currentActivity.startActivity(intent)
  • I'm programming using windows 10, Python 3.7.4, and my IDE is Pycharm, and I'm using jnius 1.3.0 (the last one at the moment) (This information may be useful)

Jacques-Joao avatar Jun 02 '20 23:06 Jacques-Joao

1/ you should be able to import both at the same time. from jnius import autoclass, cast 2/ running this code on windows won't work anyway, as you don't have access to the android api there, make sure to test on android.

tshirtman avatar Jun 02 '20 23:06 tshirtman

👋 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 27 '23 04:10 github-actions[bot]