1

Im in proccess of creating an Android application based on webview. The application loads html file from android assets into the webview.

I want to create a button the reload the webview I tried to do that using javascript:

location.reload(); 

But im getting a toast like error message that says me that this file is not exits. I wanted to try to do it with java inside my javascript interface class but I cant find way to access the webview object that is in the MainActivity.

I'd appreciate your help people!.

2
  • Try setting window.location.hreffrom javascript. Commented Feb 26, 2016 at 12:07
  • Nothing is changed. I changed the location to file:///android_asset/index.html and I still getting this message. But its logical if think, it dont have permission to access file on android. So I need to do it with java. Commented Feb 26, 2016 at 12:25

1 Answer 1

0

From your description seems more a problem connected with the way you load HTML into the WebView. But I've found that if you call in JS location.reload() the WebView seems to ignore it.

I had the idea to call, from the Android Activity, webview.reload() and trigger this call from Javascript using @JavascriptInterface.

Then some other problems arised but just for reference and posterity you can check the answer with the workaround here: Unable to reload Android WebView from Javascript

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

Comments

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.