2

I am using android studio and trying to make a mobile app using JavaScript.

I have already loaded index.html using webview.
Now I want go to ShoppingList.html which is saved in assets using the following JavaScript code.

When I use the emulator with android version 6 it works perfectly. But with android version 7 my application terminates when the Navigate() function is called.

I also tried window.locationand document.location.href but nothing works.

The JavaScript code I'm using to navigate to another html file is:

function Navigate()
{
    document.location = "file:///android_asset/www/ShoppingList.html";
}
Nope
  • 22,147
  • 7
  • 47
  • 72
Stephanie
  • 21
  • 1
  • 1
    Maybe the issue is with permissions to read a file from FS. Review permissions, please, and make sure file exists. – ilyaigpetrov May 16 '17 at 13:35
  • `my application terminates` these messages do not fly here. Post the **actual stacktrace / error** – Matt Clark May 16 '17 at 14:25
  • This is what I have got from my error log: 05-16 17:13:01.247 9294-9294/com.stephaniemartin.kitchentool E/AndroidRuntime: FATAL EXCEPTION: Process: com.stephaniemartin.kitchentool, PID: 9294 android.os.FileUriExposedException: file:///android_assets/www/ShoppingList.html exposed beyond app through Intent.getData() – Stephanie May 16 '17 at 15:18

1 Answers1

0

Putting your web resources into the assets folder, you can call webView.loadUrl("file:///android_asset/filename.html").
For Complete Communication between Java and Webview See this
and maybe this

Community
  • 1
  • 1