11

I am working on an application in Android, where I want to load a local html file using

webview.loadurl("file:///android_asset/index.html#home");

It will load ok on most devices, but on some Samsung devices with Android OS 4.0.4 , it load fails.

Do you have ideas with this issue?

Add some comments and sorry for my mistake just now.

webview.loadurl("file:///android_asset/www/index.html");

work fine , but

webview.loadurl("file:///android_asset/www/index.html#home");

failed .

binkery
  • 295
  • 1
  • 3
  • 9
  • In some devices , if the link inlcude '#' , the webview loaded failed and displayed can not found the page . – binkery Aug 04 '15 at 06:17

2 Answers2

15

First check that index.html is under asset folder in your project folder.

I believe it is under www folder within asset folder of your project.

1:First put index.html under www folder

2:put the www folder within asset folder and call

webview.loadurl("file:///android_asset/www/index.html");

Edited:

I think you might want to call the home tab of the index.html every-time when you will run the application.

As android is only concern of the html pages not the tabs here is a good way which may help you i.e.

Set the home tab active of your index.html and make other inactive.

This will might help you.

Avijit
  • 3,834
  • 4
  • 33
  • 45
  • I am sorry for my mistake , the index.html file is under my-project/assets/www/ . And webview.loadurl("file://android_asset/www/index.html"); work fine , but webview.loadurl("file:///android_asset/www/index.html#home"); failed . – binkery Nov 08 '13 at 11:18
  • So if my answer helps you accept it. It may help other users. @binkery – Avijit Nov 08 '13 at 11:20
0

this is what happen to me i misspelled it make sure you typed correctly

file://android_asset/www/index.html

not as "assets"

suriya
  • 25
  • 2