In App Reviews

82 views
Skip to first unread message

bad.idea

unread,
Feb 20, 2021, 11:30:43 AM2/20/21
to Kivy users support
Hello - didn't find any topics that matched what I was looking for on this forum or in a Google search. My app (Mobile Multibody Dynamics, check it out!) is live on the stores, and I'd like to collect more reviews. I got this working for iOS using the code below, if anyone is interested. I'd like to do something similar for Android on the Play Store. Anticipate this can be done using jnius, but being unfamiliar with Java, thought I'd see if anyone else here has done it before I try to climb that hill.

Thanks!

///

if platform == 'ios':
from pyobjus.dylib_manager import load_framework, INCLUDE
from pyobjus import autoclass
load_framework(INCLUDE.StoreKit)
SKStoreReviewController = autoclass('SKStoreReviewController')

def request_review():
try:
print('Attempting to request a review')
SKStoreReviewController.requestReview()
except:
print(' Failed!!!')

bad.idea

unread,
Feb 22, 2021, 9:18:18 PM2/22/21
to Kivy users support
No responses yet, but I made a little bit of progress in jnius. Trying to replicate the code at this link https://developer.android.com/guide/playcore/in-app-review/kotlin-java#java but in Kivy/Python.

The code fails at the `request.addOnCompleteListener` line. The Java listener syntax seems to require that you provide as an argument a task and instructions, but I don't know what the analogy would be in Python code, or if its even possible. Any ideas or recommendations about what to try next?

///

elif platform == 'android':
from jnius import autoclass, cast
PythonActivity = autoclass("org.kivy.android.PythonActivity")
currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
context = cast('android.content.Context', currentActivity.getApplicationContext())
ReviewManagerFactory = autoclass('com.google.android.play.core.review.ReviewManagerFactory')
manager = ReviewManagerFactory.create(context)
request = manager.requestReviewFlow()

def request_review():
try:
print('Attempting to request a review on Android')
# Request fails at the next line
request.addOnCompleteListener()
flow = manager.launchReviewFlow(currentActivity, request.getResult())
flow.addOnCompleteListener()
except:
print(' Failed!!!')

Robert

unread,
Feb 22, 2021, 11:13:02 PM2/22/21
to Kivy users support
I have used Listeners but not this one. So don't ask me about details of this case because I don't have the experience.

As you probably know addOnCompleteListener() is missing an argument, a specific Listener class.

by the look of it the listener class has one method onComplete with one argument of type Task.

There are pyjnius features for overloading (or some similar term?) Java classes to implement a Java class in Python (visible only from Python)
but OnCompleteListener is a abstract class, so there is no implementation to overload, 🙁 PythonJavaClass, and java_method are not going to help you.

You have to implement the abstract interface in Java.

If you don't understand the Java jargon interface and abstract class,  time to do some reading.

Once you have written the Java implementation (which will probably be less than a dozen lines), autoclass() it as you would any system Java.

In buildozer.spec reference your Java with  android.add_src =

It is actually fairly simple, figuring that out will give you some brain strain.
Reply all
Reply to author
Forward
0 new messages