Android - How to load external webpage inside WebView?

Thanks to this post I finally found the solution. Here is the code: import android.app. Activity; import android.os.

Bundle; import android.webkit. WebView; import android.webkit. WebViewClient; import android.widget.

Toast; public class Main extends Activity { private WebView mWebview ; @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); mWebview = new WebView(this); mWebview.getSettings(). SetJavaScriptEnabled(true); // enable javascript final Activity activity = this; mWebview.

SetWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Toast. MakeText(activity, description, Toast. LENGTH_SHORT).show(); } }); mWebview .

LoadUrl("http://www.google.com"); setContentView(mWebview ); } }.

Thanks to this post, I finally found the solution. Here is the code: import android.app. Activity; import android.os.

Bundle; import android.webkit. WebView; import android.webkit. WebViewClient; import android.widget.

Toast; public class Main extends Activity { private WebView mWebview ; @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); mWebview = new WebView(this); mWebview.getSettings(). SetJavaScriptEnabled(true); // enable javascript final Activity activity = this; mWebview.

SetWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Toast. MakeText(activity, description, Toast. LENGTH_SHORT).show(); } }); mWebview .

LoadUrl("http://www.google.com"); setContentView(mWebview ); } }.

1 For self finding the answer and sharing it with everyone else – momo Sep 5 at 9:33.

Please Use This code:- Main. Xml MainActivity. Java public class MainActivity extends Activity { private class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.

LoadUrl(url); return true; } } Button btnBack; WebView webview; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super. OnCreate(savedInstanceState); setContentView(R.layout. Main); webview=(WebView)findViewById(R.id.

Webview1); webview. SetWebViewClient(new MyWebViewClient()); openURL(); } /** Opens the URL in a browser */ private void openURL() { webview. LoadUrl("http://www.google.com"); webview.requestFocus(); } } Try This Code if Any Query Tell Me.

Try this webviewlayout. Xml: WebView webView; setContentView(R.layout. Webviewlayout); webView = (WebView)findViewById(R.id.

Help_webview); webView.getSettings(). SetJavaScriptEnabled(true); mWebview. LoadUrl("google.com"); Update webView.

SetWebViewClient(new WebViewController()); WbbViewController class: public class WebViewController extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view. LoadUrl(url); return true; } }.

Still have the same problem after implementing your solution... – Gilbou Sep 5 at 8:37 sorry. Seems I changed something in the manifest and now it works too. But still, the page is loaded in the web browser, not in the webview.

– Gilbou Sep 5 at 9:03 I have updated the code to force load page in webview – farhana haque Sep 5 at 10:26.

Here browser is nothing but your webview object. Now you can view web contain page wise easily.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions