I have a local website that is Javascript controlled and am loading it in a WebView. The website is really one main page with an iframe whose content changes based on user input. There is a “Next” button on the main page that runs some javascript functions and decides which page to load in the iframe (via document.getElement(…).src = )
In Android 2.1 things were working fine – simulated and on phone. The webview was loading all the pages properly.
I tested it on a 2.2 phone and whenever I click Next the page (that should be loaded in the iframe) is loaded in the default browser.
I defined an intent filter
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="file"
android:host="*"
android:pathPrefix="sdcard/Android/data/android.website/files/pages"
/>
</intent-filter>
hoping that it would redirect the page requests to the activity, but it doesn’t work. The url is still loaded by the browser.
Using shouldOverredeUrlLoading doesn’t work well because the link that is loaded is the one of the internal frame. I tried loading instead javascript code that sets that url as the src of the iframe, but didn’t work.
It’s weird that this only happens on the 2.2 phone. In a 2.2 emulator it works fine.
Any ideas?
Try providing your own
WebViewClientto WebView. You should overrideshouldOverrideUrlLoading(..)and returnfalse.