I’ve got webview that I’m trying to load (and re-load) from local html documents (not over the network).
On Android, the webview screen briefly shows a white background with the Android logo and a message something like “The webpage you requested corona:mylink cannot be found” (where ‘mylink’ is text I’ve put into the html so I can easily detect the user’s click).
Is there any way to get around this?
I can set a 700+ msec delay and it basically goes away, but there must be some cleaner way to get rid of this.
Why is Android/Chromium even trying to process the link? shouldn’t it just hand it off to my url-handler?
local function handleTransition( obj ) -- make text slide in from the right --obj.x = 1.1 \* display.contentWidth -- parse the Twine code and process the template local pn = flipPageName() dprint( 5, "starting to parse ["..settings.currentPassage.."] (ht2) \<"..pn.."\>" ) ProcessTemplate( pn, settings.currentPassage ) -- the obj argument is the webview obj:request( pn, system.DocumentsDirectory ) -- move the webview so we can slide it in from the right obj.x = 1.1 \* display.contentWidth transition.to( obj, { alpha = 1, x = display.contentWidth \* 0.50, time = 600 }) return true end local function handleUrlEvent( event ) local webview = scene.webview local url = event.url dprint( 5, "caught url ["..url.."]" ) dprint( 5, " name is [".. event.name .."]" ) -- android has issues with the event.type field .. doesn't always exist?? if( event.type == nil ) then dprint( 5, " type is [nil]" ) else dprint( 5, " type is [".. event.type .."]" ) if( event.type == "link" ) then local i,j = string.find(url,"corona:") if( i ~= nil ) then local s = url:sub(j+1) dprint( 5, "jumping to ["..s.."]" ) if( s == "mainmenu" ) then -- webview is cleaned up in exitScene storyboard.gotoScene( "scripts.MainScreen" ) else -- TODO: should send the new passage as a param -- we'll do global var for now -- make the text slide off to the left settings.currentPassage = s transition.to( webview, { alpha = 0, x = -1.1 \* display.contentWidth, time = 500, onComplete = handleTransition }) end else if( url:sub(1,4) == "http" ) then system.openURL( url ) end end end end --return true end
I will also say that when I run on the Android emulator, I see a strange Chromium error:
D/chromium( 527): Unknown chromium error: -6 ... D/TilesManager( 527): new EGLContext from framework: 2a13ff38 D/GLWebViewState( 527): Reinit shader D/GLWebViewState( 527): Reinit transferQueue