Java tutorial
//package com.java2s; //License from project: Open Source License import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; public class Main { @Nullable static Uri safeUri(@NonNull String url) { if (TextUtils.isEmpty(url)) { return null; } Uri uri = Uri.parse(url); if (uri.getHost() == null || uri.getScheme() == null) { return null; } return uri; } }