8

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} 

3 Answers 3

27

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

Sign up to request clarification or add additional context in comments.

1 Comment

n.p. I was dealing with the same problem. BTW it helps to revisit your own questions and add solution if you found one. I try to do that when I won't get a clear answer and later find answer somewhere else
2

Does the same thing happen with a different URL? I'm wondering if mobile.twitter.com has a redirect which is causing the Browser to be launched.

4 Comments

hey how to rectify that? i want to load only in my webview.. actually i m passing the url value : twitter.com/brownuniversity/statuses/8963488831 but its automatically loads. what can i do mate?
i am getting this problem in twitter's url only man.. but how can i solve it?
This is poorly qualify as answer. Should probably be just a comment
Agreed that this is a poor answer, maybe you should approve the solution below.
2

you need add setting for app Follow:

mWebView.getSettings() .setUserAgentString( "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3");

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.