Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

WebView showing blank page when loading page from temporary or caches directory
Started by fabriciomssspam Jun 28 2018 01:52 PM

No replies to this topic
android webview phone blank
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

fabriciomssspam

[GLOBAL: userInfoPane.html]
fabriciomssspam
  • Observer

  • 1 posts
  • Corona SDK

Guys this thing is driving me crazy.

 

I have a local HTML file that i want to display inside a webview.

This file is changed dynamically so i cant leave it inside system.ResourceDirectory.

 

I tested it on phone simulator and everything goes well.

 

The problem is, when I test it on real phone the webview page doesn't show. Just a blank scene.

 

The problem only happened if I place the requested file inside system.TemporaryDirectory or system.CachesDirectory. If I use system.ResourceDirectory the page is displayed correctly.

 

Here is the code to display it.

	local myFilePath = htmlPath
        print("Requested File: "..myFilePath)
	
	local webView = native.newWebView(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight )
	webView:request( myFilePath )
	print("LoadedHTML")
	local file = io.open(myFilePath, 'r')
		print(file:read( "*a" ))
	io.close(file)

As you can see I checked if the file is empty, but that is not the case. (Of course, when I tried it with ResourceDirectory I get an expected error on io.open but the webview is displayed correctly behind the error message)

 

Do i need special permission or something like that to request page from cache or temp folder?

 

BTW I am using android 7.0, don't know if it matters.

 

 




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: android, webview, phone, blank