Android validating a url
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.
is Valid Url returns false for the following URL, although the device seems happy enough with it (it's missing the double slash after file:).
The problem with all suggested approaches: all Reg Ex is validating All Reg Ex -based code is over-engineered: it will find only valid URLs!
As a sample, it will ignore anything starting with " and having non-ASCII characters inside. #Beliebers Pray For Avalanna"); "@Andy Samuels31 Hahahahahahahahahhaha lol, you don't look like a girl hahahahhaahaha, you are...
This worked nicely for me./* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * * * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Pattern; /** * Commonly used regular expression patterns.
Search for android validating a url:
How to test that your app is set up to communicate referrer information to Localytics If you're familiar with using Android Debug Bridge, we have developer instructions on how to test attribution locally.