1

I am writing an Android app using Python and SL4A. The app uses a webview that I wish to refresh. I plan on doing this by utilising javascript location.replace() within a wrapping doRefresh() javascript function. The problem I have is that I do not know how to call the javascript function from within my main event loop within the Python code.

Is there a way to directly call the method?

or

Is there a way to indirectly call the method say via a button's onClick and a mimic screen tap?

Thanks.

1 Answer 1

2

You'll need to wait for a refresh event (this would be a custom event) in your JavaScript that is waiting for an event posted from your Python script. The only communication layer between JavaScript and Python is via events.

Sign up to request clarification or add additional context in comments.

1 Comment

Damon's answer is correct. There's a detailed explanation here: pythoncentral.org/python-for-android-using-webviews-sl4a (Note: I drafted this article.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.