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

  • SEARCH
  • Home
  • 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 4596896
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:10:49+00:00 2026-05-21T23:10:49+00:00

I want to take input, a URL or just a website name like, www.google.com

  • 0

I want to take input, a URL or just a website name like, http://www.google.com from EditText in Android and on user click on the Button to submit or when the EditText looses the focus the URL should be validated,
like it is in the format “http://www.anyURL.com“…

How can I do this? Is there any inbuilt functionality available in android?

  • 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-21T23:10:50+00:00Added an answer on May 21, 2026 at 11:10 pm

    Short answer

    Use WEB_URL pattern in Patterns Class

     Patterns.WEB_URL.matcher(potentialUrl).matches()
    

    It will return True if URL is valid and false if URL is invalid.

    Long answer

    As of Android API level 8 there is a WEB_URL pattern. Quoting the source, it "match[es] most part of RFC 3987". If you target a lower API level you could simply copy the pattern from the source and include it in your application. I assume you know how to use patterns and matchers, so I’m not going into more details here.

    Also the class URLUtil provides some useful methods, e.g:

    • isHttpUrl()
    • isValidUrl()

    The descriptions of the methods are not very elaborate, therefore you are probably best of looking at the source and figuring out which one fits your purpose best.

    As for when to trigger the validation check, there are multiple possibilities: you could use the EditText callback functions

    • onFocusChanged(), or
    • onTextChanged()

    or use a TextWatcher, which I think would be better.

    DON’T USE URLUtil to validate the URL as below.

     URLUtil.isValidUrl(url)
    

    because it gives strings like "http://" as valid URL which isn’t true

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Requirement is like: I want to take input values from user in frame but
What if I want to take user input from the args[0] array, but just
I want to have a form on my page take user input, a URL
I want to make a program in Python that can take video input from
I want to write a script in AutoIt, which can take automatic input from
I have a html form. I want to take the input value (a url),
I have some Java code like int userid = take user input; And then
I want to get response from websites that take a simple input, which is
I want to take multiple integer inputs in same line eg :- input -1
I want to create an input form that will take the input text and

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.