Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webview.loadUrl() problem in android?

Tags:

android

I am loading a URL whose datatype is String in a WebView. Using something like:

webview.loadUrl(string_variable);

but it is automatically redirected to the browser.

I got this in my LOGCAT,

02-13 14:11:08.586: INFO/ActivityManager(5Cool: Displayed activity com.example.brown/.Bru_Press_MostRecent_ArticleView: 2583 ms (total 2583 ms)
02-13 14:11:09.376: INFO/ActivityManager(5Cool: Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://mobile.twitter.com/brownuniversity/statuses/8681812931 cmp=com.android.browser/.BrowserActivity (has extras) }
02-13 14:11:09.506: INFO/ActivityManager(5Cool: Start proc com.android.browser for activity com.android.browser/.BrowserActivity: pid=285 uid=10014 gids={3003, 1015}
like image 236
Praveen Avatar asked Feb 13 '10 09:02

Praveen


1 Answers

You can remedy this by overriding your WebView's WebViewClient. All it takes is something like this:

    webView = (WebView) findViewById(R.id.webView);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
           return super.shouldOverrideUrlLoading(view, url);
        }
    });

Just be aware that WebView is more limited than full blown browser

like image 197
Bostone Avatar answered Sep 24 '22 20:09

Bostone