1

My app uses a native browser (webview), which is used to browse a certain website. While browsing the website, if the user switches from mobile data(2G, 3G) to wifi or vice-versa, there is a change in IP. When that happens the browser stops receiving any data from the server (website).

Does anyone know how to handle this situation. I was thinking of somehow detecting this IP change and re-establishing a connection with the server. Would this be a good solution. If yes, then how do I re-establish the connection between the native browser and the server?

Any help would be hugely appreciated. Thanks in advance

Rakib Ansary
  • 4,078
  • 2
  • 18
  • 29

1 Answers1

1

Shouldn't it be as easy as refreshing the page on an connection type change?

DanRedux
  • 9,119
  • 6
  • 23
  • 41
  • How do I detect a "connection type change?" Refreshing doesn't seem to work. – Rakib Ansary Mar 12 '12 at 19:24
  • If you refresh the WebView, it should automagically use the new Connection type. When to refresh the webview? Polling for IP changes would work, but I'd do some hard Googling for a "conectionChange" event of some kind – DanRedux Mar 12 '12 at 19:26
  • I've figured out how to detect connection change from http://stackoverflow.com/questions/7205720/how-to-handle-wifi-to-mobile-network-switch-programatically However, refresh doesn't work? Any ideas why? – Rakib Ansary Mar 12 '12 at 21:23
  • Probably because when the WebView is created it inializes its networking stuff. Destroy and recreate the webview on change. – DanRedux Mar 12 '12 at 21:37
  • I tried destroying the webview and the re-creating it, but even that doesn't work. `webview.destroy(); webview = null(); webview = new WebView(this); ... ` – Rakib Ansary Mar 13 '12 at 11:15