Android WebPopup problem with pseudo-URLs

I’m using the native WebPopup for some of the UI in my game (settings, integration with social networks).

In the case of settings I communicate with the Lua code via pseude-URLs and a listener as shown in the documentation. I not only use it for closing the view but also to inform the Lua based game code of some changes in the settings (e.g. tapping on “no music” immediately turns background music off, not just after the web view is closed).

This works very well on iOS, but unfortunately not on Android. The pseudo-URLs cause the browser to actually try to load them and of course fails in doing so. The web view will show an error:

Error web view on Android

[text]
Web page not available

The Web page at view:green might be temporarily down or it my have moved permanently to a new web address.


[/text]

This is the example code that works well on iOS, but causes the problem on Android (tested on Nexus S with Android 2.3.4).

main.lua

if system.getInfo("platformName") ~= "Android" then  
 display.setStatusBar(display.HiddenStatusBar)  
end  
  
local testHeight = 20  
  
local test = display.newRect(0, 0, display.contentWidth, testHeight)  
test:setFillColor(255, 255, 255, 255)  
  
local function listener(event)  
 local shouldLoad = true  
  
 if string.find(event.url, "view:close") == 1 then  
 shouldLoad = false  
 elseif string.find(event.url, "view:green") == 1 then  
 test:setFillColor(0, 255, 0, 255)  
 elseif string.find(event.url, "view:red") == 1 then  
 test:setFillColor(255, 0, 0, 255)  
 end  
  
 return shouldLoad  
end  
  
local webPopupOptions = {  
 hasBackground = true,  
 baseUrl = system.ResourceDirectory,  
 urlRequest = listener  
}  
  
native.showWebPopup(0, testHeight, display.contentWidth, display.contentHeight, "test.html", webPopupOptions)  

test.html

  
[html]  
  
<meta charset="utf-8">

<title>Test</title>
  
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  
  
  

# Test
  

  
- [Close](view:close)
  
- [Green](view:green)
  
- [Red](view:red)
  
  
  
[/html]  

Is this a known problem on Android? If so when will this be fixed? Or is there any workaround for this? It would take too much work to change all my web based UI just for Android. Please give me some advice.

Thomas
[import]uid: 8460 topic_id: 12020 reply_id: 312020[/import]

I’m having the same problem, this is also quite vital for us.

Is there any fix atm? I’m working out some voodoo with my web pages and my client code, but so far no luck.

EDIT: upon reading more carefully, I don’t think I have the exact same problem, actually. I’m using redirects to pass some information into my app, and I don’t receive the URL events from JS redirects, only from button-based redirects. [import]uid: 8145 topic_id: 12020 reply_id: 48799[/import]

Yeah known problem on Android, not a Corona thing.

Did you find a workaround as I’m having the same issues. [import]uid: 5354 topic_id: 12020 reply_id: 66673[/import]

Is there a work around? I am having the same problem… [import]uid: 58885 topic_id: 12020 reply_id: 95789[/import]

Everyone,

This is a known problem on Android. Its web browser only support URL schemes HTTP and HTTPS. All other URL schemes cause the browser to display an error. We have this issue written up on our side for us to make it work more like iOS does it, but it is low priority at the moment amongst everything else we need to do.

The only known work-around at the moment is to set up a Lua listener to catch the URL being loaded and then calling system.openURL() for URL schemes other than HTTP and HTTPS. The only issue with this method is that the browser will continue to load the page, so you’ll be forced to close and re-open it.

If the intent is to only send information to Corona via its Lua listener, that is, you don’t want it to load anything such as mailto, then perhaps you should consider setting up a URL that points to the same page, but with an argument appended to the end of it to signal the app to do something. A lot of web apps do it this way. [import]uid: 32256 topic_id: 12020 reply_id: 96347[/import]