user2310841
user2310841

Reputation: 21

webview comes and disappered within milliseconds

Oncreate method run and it shows web view and just disappeared within milliseconds on application run.

I have search for other similar questions on stackoverflow.com and use same code.

Sorry for simple question but I am beginner.

 private WebView webview;
        private static final String TAG = "Main";
        private ProgressDialog progressBar;  

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            requestWindowFeature(Window.FEATURE_NO_TITLE);

            setContentView(R.layout.launch_page);

            webview = (WebView)findViewById(R.id.web_view);
            webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
           // WebSettings settings = webview.getSettings();
            webview.setWebViewClient(new WebViewClient() {
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                   return super.shouldOverrideUrlLoading(view, url);
                }
            });

            webview.loadUrl("http://www.google.com");
        }

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <WebView android:id="@+id/web_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" />
</LinearLayout>

errors 07-27 15:48:27.270: E/ActivityThread(4160): Activity com.green.iyengertv.FirstLaunch has leaked IntentReceiver com.android.qualcomm.browsermanagement.BrowserManagement$1@4145b4d8 that was originally registered here. Are you missing a call to unregisterReceiver()? 07-27 15:48:27.270: E/ActivityThread(4160): android.app.IntentReceiverLeaked: Activity com.green.iyengertv.FirstLaunch has leaked IntentReceiver com.android.qualcomm.browsermanagement.BrowserManagement$1@4145b4d8 that was originally registered here. Are you missing a call to unregisterReceiver()?

Upvotes: 1

Views: 573

Answers (2)

falcon
falcon

Reputation: 362

remove

        webview.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
               return super.shouldOverrideUrlLoading(view, url);
            }
        });

and that's all.

why do you need it if you do nothing?

Upvotes: 0

Salman Khakwani
Salman Khakwani

Reputation: 6714

Just change this line of code in your shouldOverrideUrlLoading(....) Method

Instead of using return super.shouldOverrideUrlLoading(view, url);

 view.loadUrl(url);
 return false;


if you return true; in this method, then an external WebView will be opened and the redirected URL will be opened there.
if you return false; in this method, then the requests will be handled within your WebView.

Upvotes: 0

Related Questions