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 985261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:08:19+00:00 2026-05-16T05:08:19+00:00

In the browser, you can longClick on URLs. In my WebView, you cannot. How

  • 0

In the browser, you can longClick on URLs. In my WebView, you cannot. How can I make it so you can?

  • 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-05-16T05:08:20+00:00Added an answer on May 16, 2026 at 5:08 am

    I had this same problem.

    Unfortunately, I could not find a way to make the standard browser menu options appear. You have to implement each one yourself. What I did was to register the WebView for context menus with activity.registerForContextMenu(webView). Then I subclassed the WebView and overrode this method:

    @Override
    protected void onCreateContextMenu(ContextMenu menu) {
        super.onCreateContextMenu(menu);
    
        HitTestResult result = getHitTestResult();
    
        MenuItem.OnMenuItemClickListener handler = new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                    // do the menu action
                    return true;
            }
        };
    
        if (result.getType() == HitTestResult.IMAGE_TYPE ||
                result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
            // Menu options for an image.
            //set the header title to the image url
            menu.setHeaderTitle(result.getExtra());
            menu.add(0, ID_SAVEIMAGE, 0, "Save Image").setOnMenuItemClickListener(handler);
            menu.add(0, ID_VIEWIMAGE, 0, "View Image").setOnMenuItemClickListener(handler);
        } else if (result.getType() == HitTestResult.ANCHOR_TYPE ||
                result.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
            // Menu options for a hyperlink.
            //set the header title to the link url
            menu.setHeaderTitle(result.getExtra());
            menu.add(0, ID_SAVELINK, 0, "Save Link").setOnMenuItemClickListener(handler);
            menu.add(0, ID_SHARELINK, 0, "Share Link").setOnMenuItemClickListener(handler);
        }
    }
    

    If you want to do something other than a context menu, then use an OnLongClickListener. However you want to intercept the long click event, the HitTestResult is the key. That’s what will allow you to figure out what the user clicked on and do something with it.

    I haven’t actually implemented “Save Link” myself, I just included it as an example here. But to do so you would have to do all the processing yourself; you’d have to make an HTTP GET request, receive the response, and then store it somewhere on the user’s SD card. There is no way that I know of to directly invoke the Browser app’s download activity. Your “Save Link” code will look something like this:

    HitTestResult result = getHitTestResult();
    HttpClient httpclient = new DefaultHttpClient();
    HttpGet httpget = new HttpGet(result.getExtra());
    HttpResponse response = httpclient.execute(httpget);
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        URL url = new URL(result.getExtra());
    
        //Grabs the file part of the URL string
        String fileName = url.getFile();
    
        //Make sure we are grabbing just the filename
        int index = fileName.lastIndexOf("/");
        if(index >= 0)
                fileName = fileName.substring(index);
    
        //Create a temporary file
        File tempFile = new File(Environment.getExternalStorageDirectory(), fileName);
        if(!tempFile.exists())
                tempFile.createNewFile();
    
        InputStream instream = entity.getContent();
        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
        //Read bytes into the buffer
        ByteArrayBuffer buffer = new ByteArrayBuffer(50);
        int current = 0;
        while ((current = bufferedInputStream.read()) != -1) {
                buffer.append((byte) current);
        }
    
        //Write the buffer to the file
        FileOutputStream stream = new FileOutputStream(tempFile);
        stream.write(buffer.toByteArray());
        stream.close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have bookmarkable URLs that the browser can capture and handle. If
Opera mini browser can save HTML pages in OBML (Opera Binary Markup Language) format
In HTML, how do you link to a file that the browser can only
Other than using browser,How can I get the public key of a websites which
How can the browser tell where I am? Totally based on registered IP address?
How I can capture browser restore/maximize event in jQuery or javascript? We can use
Is there any way that I can detect browser type on routing and use
I just decided to replace phpMyAdmin by Mysql Query Browser ( finally I can
I want to know that whether on a php page we can get browser
Debugging a PHP program, is there any add-on/plug-in for browser which I can view

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.