WebView not working, launching the url externally in browser. Displaying webpage inside app
android, android-intent, facebook, webview, xml
Solution
As per this answer: How to load external webpage inside WebView you need to set a WebViewClient before you call `loadUrl`:
webView.setWebViewClient(new WebViewClient());
The reason you're being sent to the browser is that if no WebViewClient is set then the default action for navigations is to forward them to the browser.
Problem
I made a home or main activity which has some icons and one of them is facebook, and by clicking it a facebook.xml is launched via intent The code for that xml page is set as below: ``` <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:weightSum="10" android:id="@+id/webView" > </WebView> ``` And I want to load the url: "http://www.j.mp/tkf4mApp" The Java file which is linked to this xml file is as below: ``` import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class Facebook extends Activity { private WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.facebookpage); webView=(WebView)findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl("http://www.j.mp/tkf4mApp"); } } ``` But instead of showing webpage inside the app in facebook.xml it launches browser externally, but i want it to be shown inside the app.