[SOLVED] How do I make Ren'Py call a function in PythonSDLActivity.java? (Android)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
storykween
Regular
Posts: 154
Joined: Mon Sep 30, 2013 1:17 pm
Completed: Serafina's Saga, Quantum Conscience, Echoes of the Fey, miraclr - Divine Dating Sim
Organization: Woodsy Studio
Location: St Louis
Contact:

[SOLVED] How do I make Ren'Py call a function in PythonSDLActivity.java? (Android)

#1 Post by storykween »

I'm looking for a way to schedule local notifications on Android devices. I don't believe there's a function in Ren'Py that can do this, but I figured out how to do it in Android Studio. However, I need to trigger a function in Android Studio from my code in Ren'Py.

I see the vibrate() and openURL() functions being called in PythonSDLActivity.java and using variables set in Ren'Py, so I would like to create my own function that can push variables to Java. In my attempts so far, I can change the vibrate function in Java to push a generic notification, but nothing happens when I make a new function or make changes the to vibrate function in Ren'Py (exports.py).

Can anyone help me with this? Thanks in advance!
Last edited by storykween on Thu Jul 27, 2017 4:58 pm, edited 1 time in total.
Image
My website: woodsy-studio.com

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How do I make Ren'Py call a function in PythonSDLActivity.java? (Android)

#2 Post by PyTom »

You want to use pyjnius.

https://github.com/kivy/pyjnius

Code: Select all

init python:
    import jnius
    PythonSDLActivity = jnius.autoclass("org.renpy.android.PythonSDLActivity")

python:
    PythonSDLActivity.myStaticMethod(1, 2, "Flan")
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
storykween
Regular
Posts: 154
Joined: Mon Sep 30, 2013 1:17 pm
Completed: Serafina's Saga, Quantum Conscience, Echoes of the Fey, miraclr - Divine Dating Sim
Organization: Woodsy Studio
Location: St Louis
Contact:

Re: How do I make Ren'Py call a function in PythonSDLActivity.java? (Android)

#3 Post by storykween »

Awesome, we got that to work! Thanks so much! :D
Image
My website: woodsy-studio.com

Post Reply

Who is online

Users browsing this forum: GoldenGob, SelLi