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

I can't import caste #543

Closed
Jacques-Joao opened this issue Jun 2, 2020 · 2 comments
Closed

I can't import caste #543

Jacques-Joao opened this issue Jun 2, 2020 · 2 comments
Labels

Comments

@Jacques-Joao
Copy link

Jacques-Joao commented Jun 2, 2020

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)
@tshirtman
Copy link
Member

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.

@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