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

Android 5.1 PythonActivity.mActivity Stuck #280

Open
331319341 opened this issue Jun 15, 2017 · 4 comments
Open

Android 5.1 PythonActivity.mActivity Stuck #280

331319341 opened this issue Jun 15, 2017 · 4 comments
Milestone

Comments

@331319341
Copy link

331319341 commented Jun 15, 2017

74765882-7fe9-44be-855b-b2163729b3c8


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

@KeyWeeUsr
Copy link
Contributor

@331319341 so, we have the log, that's good, but it's not complete (the log should end with Python for android ended or something like that). What we don't have is what's wrong with it or at least some code that could reproduce it. Buildozer/P4A files used for creating the APK would be nice too. Please include the requested stuff :)

@331319341
Copy link
Author

from jnius import cast
from jnius import autoclass

import the needed Java class

PythonActivity = autoclass('org.renpy.android.PythonActivity')
Intent = autoclass('android.content.Intent')
Uri = autoclass('android.net.Uri')

create the intent

intent = Intent()
intent.setAction(Intent.ACTION_VIEW)
intent.setData(Uri.parse('http://kivy.org'))

PythonActivity.mActivity is the instance of the current Activity

BUT, startActivity is a method from the Activity class, not from our

PythonActivity.

We need to cast our class into an activity and use it

currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
currentActivity.startActivity(intent)

The website will open.

@331319341
Copy link
Author

image

@331319341
Copy link
Author

8ac34446-5f8e-473b-80bf-0193be4e9f33

@KeyWeeUsr KeyWeeUsr modified the milestones: 1.1.4, 1.1.5 Nov 28, 2018
@KeyWeeUsr KeyWeeUsr modified the milestones: 1.2.0, 1.2.1 Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants