Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8209159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:37:30+00:00 2026-06-07T09:37:30+00:00

package com.webview; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.webkit.WebView; import android.webkit.WebViewClient;

  • 0
    package com.webview;

    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;


    public class Webview_integrationActivity extends Activity {


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

            WebView mywebview = (WebView) findViewById(R.id.webView1);
            mywebview.setWebViewClient(new MyWebViewClient());



        WebViewClient client = new MyWebViewClient()
        {
            @Override
            public void launchExternalBrowser(String url) {
                 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                 startActivity(intent);
            }

        };
    }
    }


***************************************************************************************


package com.webview;


import android.content.Intent;
import android.net.Uri;

import android.webkit.WebView;
import android.webkit.WebViewClient;

public abstract  class MyWebViewClient extends WebViewClient {

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (Uri.parse(url).getHost().equals("www.google.com")) {
            // This is my web site, so do not override; let my WebView load the page
            return false;
        }
        // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

        launchExternalBrowser(url);    

        return true;

}

    public abstract void launchExternalBrowser(String url);



}

**I am getting the error as “Cannot instantiate the type MyWebViewClient” when I am running this program.I know that’s because that class is abstract.But how to resolve my issue.I have pasted the code for both the classes that I am using.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:37:31+00:00Added an answer on June 7, 2026 at 9:37 am
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.Button;
    
    
    public class Webview_integrationActivity extends Activity {
    
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            final WebView mywebview = (WebView) findViewById(R.id.webView1);
            mywebview.setWebViewClient(new WebViewClient());
    
            Button button1 = (Button) findViewById(R.id.My_btn);
            button1.setOnClickListener(new OnClickListener() {
    
                         @Override
                         public void onClick(View v) {
    
    
    
                              startActivity(new Intent(
                                           "android.intent.action.VIEW",
                                            Uri.parse("https://www.google.com")));
                               // TODO Auto-generated method stub
                              }
    
                  });
    
        }
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if (Uri.parse(url).getHost().equals("www.google.com")) {
                    // This is my web site, so do not override; let my WebView load the page
                    return false;
                }
                // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    
                startActivity(intent);
    
                return true;
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package com.example.t2noob; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri;
I'm running the following code.... package com.dc; import android.app.Activity; import android.content.Intent; import android.net.Uri; import
I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
package com.duncan.hello.world; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button;
package com.parseador.prueba; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; public class main extends
my code is Here java file package org.example.webviewdemo; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView;
package com.org.myOxygen.activities; import java.util.Stack; import android.app.Activity; import android.app.ActivityGroup; import android.app.LocalActivityManager; import android.content.Intent; import android.os.Bundle;
package com.commonsware.android.threads; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.view.View.OnClickListener;
This is my FragmentListArraySupport.java package com.test.methods; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.ListFragment; import android.util.Log;
aka, what is wrong with this code:- package com.mez.appofjaq; import com.mez.appofjaq.RssParser.RssFeed; import android.app.Activity; import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.