I am writing an application to launch webView in my activity. But it was launched in web browser.
I refer the links and this tutorial too
But When i used shouldOverrideUrlLoading
, i can get only blank screen.
For that issue i refered this link
But no one help in my case..
I have given my code.
Please note what mistake I have done?
My code is:
webview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical" >
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal|center_vertical" >
</WebView>
</LinearLayout>
WebViewActivity.java
public class webViewActivity extends Activity {
private WebView webView;
private String strUrl;
public final String TAG = "webViewActivity";
ProgressBar progBar;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.webview);
Bundle bundle = getIntent().getExtras();
strUrl = bundle.getString("URL");
Log.d(TAG, "link is " + strUrl);
// strUrl = "www.google.com";
webView = new WebView(this);
webView.loadUrl(strUrl);
// progBar = (ProgressBar)findViewById(R.id.progWeb);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(strUrl);
return true;
}
});
}
Please help to corect my mistake.
Thank you in Advance!!